> HTML_escape(textilize(“< / body> Foo”))会破坏纺织品
> textilize(HTML_escape(“< / body> Foo”))可以工作,但会打破各种纺织品功能,如链接(写作“linkname”:http://www.wheretogo.com/),因为引号会被转换进入& quot;因此不再被纺织品检测到.
>消毒不会做得更好.
有关那个的任何建议吗?我宁愿不使用TIDy来解决这个问题.
提前致谢.
def safe_textilize( s ) if s && s.respond_to?(:to_s) doc = RedCloth.new( s.to_s ) doc.filter_HTML = true doc.to_HTML endend
摘自文档:
总结Accessors for setting security restrictions.
This is a nice thing if you‘re using RedCloth for formatting in
public places (e.g. Wikis) where you don‘t want users to abuse HTML for bad things.If
filter_HTML
is set,HTML which wasn‘t created by the Textile processor will be
escaped. Alternatively,ifsanitize_HTML
is set,HTML can pass through the Textile processor but unauthorized Tags and attributes will be removed.
以上是内存溢出为你收集整理的我如何纺织和消毒HTML?全部内容,希望文章能够帮你解决我如何纺织和消毒HTML?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)