如何在数据库中保存HTML格式 [英] How to save HTML formatting in database

查看:1046
本文介绍了如何在数据库中保存HTML格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以html格式将文本保存在MySql数据库中.如果我将html格式保存在数据库中,是否会使我的网站容易受到攻击?

并且我应该为需要保存html格式的特定字段选择哪种数据类型.

I want to save my text with html formatting in my MySql Database. If I save html formatting in database, will it make my site vulnerable or not?

And What data type should I choose for that particular field in which I need to save my html formatting.

推荐答案

如果您将html作为普通文本处理,并且使用参数,那么您应该很安全.

对于数据类型,您可以使用文本.有关更多信息,请参见: http://dev.mysql.com/doc/refman/5.0/en /blob.html [^ ]
If you''re handling the html as normal text and using parameters then you should be quite safe.

For the data type you can use text. For more info see: http://dev.mysql.com/doc/refman/5.0/en/blob.html[^]


使用html编码,可能会转换为base64字符串

它会使我的网站变得脆弱吗?是的.可以注入Javascript.

我应该为需要保存html格式的特定字段选择哪种数据类型. =会成为Blob
Use html encoding and may be convert to base64 string

will it make my site vulnerable or not? Yes. Javascript injection is possible.

And What data type should I choose for that particular field in which I need to save my html formatting. = Would be a blob


这篇关于如何在数据库中保存HTML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆