rails.strip_tags for html with carriage return

試著忘記壹切 提交于 2019-12-14 02:17:11

问题


Following code converts \r to is it correct?

strip_tags "<a>aaa</b>\r\n<!-- aaa -->" # => "aaa&#13;\n"

is it correct? I supposed to receive

"aaa\r\n"

回答1:


I've encountered the same issue recently. I've tested on both rails 4.0.12 and 4.2.0, and only saw aaa&#13\n on 4.2.0. So I guess it might be an issue in the later version.




回答2:


fixed there: https://github.com/rails/rails-html-sanitizer/issues/31

The reason is related to encoding special characters.

Some related bugs are fixed in Rails 4.2.1



来源:https://stackoverflow.com/questions/28896700/rails-strip-tags-for-html-with-carriage-return

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!