问题
Following code converts \r to is it correct?
strip_tags "<a>aaa</b>\r\n<!-- aaa -->" # => "aaa \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
\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