So before you made that change,
I asked you to think about whether it
would be better to clean bad stuff out
of posts as soon as the user sends them,
before we put them in the database or
whether we should put them
into the database as they are and
clean them up before we display them.
It turns out that there
are arguments both ways.
Usually you'll hear programmers talk
about input sanitization, meaning that
we clean bad stuff out of user input,
before we do anything at all with it,
that way if someone later displays
the stored posts using another app.
They don't have to worry about bad
stuff hiding, in the database.
But on the other hand, if we wanted
an accurate record of what users have
sent to us, maybe we want to preserve
bad input in the database, and
do output sanitization instead.
People have different opinions,
about which of these is best.
Right now, since we already have
live bad stuff in the database,
we definitely need to sanitize output.
But we could sanitize input as well.
،قبل إجراء ذلك التغيير
طلبت منكم التفكير فيما
إذا كان من الأفضل إزالة الأشياء السيئة
من المنشورات بمجرد قيام المستخدم بإرسالها
وقبل قيامنا بوضعها في قاعدة البيانات أم
إذا كان يتعين وضعها
في قاعدة البيانات كما هي بحالتها
.وتنظيفها قبل عرضها
واتضح وجود
.وسائط تقوم بالطريقتين
تسمعون عادة حديث المبرمجين
حول تطهير المدخلات، وهو يعني
إزالة الأشياء السيئة من إدخال المستخدم
،قبل القيام بأي شيء معها على الإطلاق
وبهذه الطريقة إذا قام فرد في وقت لاحق بعرض
.المنشورات المخزنة باستخدام تطبيق آخر
فلا داع من القلق بشأن
.الأشياء السيئة المخفية في قاعدة البيانات
وعلى الجانب الآخر، إذا كنا أردنا
سجل دقيق يحوي الأشياء
التي أرسلها المستخدم لنا، فربما نريد المحافظة
على المدخلات السيئة في قاعدة البيانات
.وإجراء تطهير للمخرجات بدلاً من ذلك
تختلف آراء الناس بشأن
.الأفضل بين الخيارين
في الوقت الحالي، نظرًا لوجود
،أمور سيئة مباشرة في قاعدة البيانات
.فيلزم من المؤكد تطهير المخرجات
.ولكن يمكن تطهير المدخلات كذلك
Antes de você fazer essa alteração,
pedi para você pensar sobre se seria
melhor apagar as coisas ruins
das postagens assim que elas forem enviadas pelo usuário,
antes de as colocarmos no banco de dados ou
se devemos colocá-las
no banco de dados como estão e
limpá-las antes de as exibirmos.
Acontece que existem
argumentos para os dois lados.
Geralmente, você ouvirá os programadores falarem
sobre a sanitização de entrada, no sentido de
que apagamos as coisas ruins da entrada do usuário,
antes de fazermos qualquer coisa com ela,
dessa forma, se alguém depois exibir
as postagens armazenadas usando outro aplicativo,
eles não precisam se preocupar em ocultar
coisas ruins no banco de dados.
Mas por outro lado, se quiséssemos
um registro preciso do que os usuários nos
enviaram, talvez fosse melhor preservar a
entrada incorreta no banco de dados, e
fazer a sanitização da saída em vez disso.
As pessoas têm opiniões diferentes
sobre o que é melhor.
Agora, como já temos
coisas ruins publicadas no banco de dados,
definitivamente precisamos sanitizar a saída.
Mas poderíamos sanitizar a entrada também.
在你开始修改之前 我要你思考一下
是应该在用户发来垃圾信息的时候就清理掉它们
在把它们放进数据库之前 还是应该先把所有内容放入数据库
然后在我们显示它们之前清理掉垃圾信息呢
其实这两种方式都存在辩护者
你经常会听到开发者讨论输入净化的问题
也就是我们在对内容做任何操作之前先清理掉有害的内容
这种方式下 如果使用其他应用来显示所存的贴子
就不用担心在数据库中会藏着破坏性的东西了
但另一方面 如果我们想要获得一份精确的纪录
呈现出用户都发了什么那么我们就需要在数据库里存下这些有害的输入
然后使用输出净化
人们对哪个方案更好抱有不同的看法
现在 考虑到我们的数据库里已经有了有害的东西
我们肯定是需要输出净化的
但我们也可以做一下输入净化