rails / rails-html-sanitizer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`sanitize` inserts unintended whitespace

yskkin opened this issue · comments

By executing following test.rb file via rails runner test.rb,

test_str="<li><span>foo</span>bar</li>"

sanitizer = Rails::Html::WhiteListSanitizer.new

sanitized = sanitizer.sanitize(test_str)
puts `bash -c 'diff -u <(echo "#{test_str}") <(echo "#{sanitized}")'`

I got this output:

Running via Spring preloader in process 73791
--- /dev/fd/63	2017-04-26 17:58:44.000000000 +0900
+++ /dev/fd/62	2017-04-26 17:58:44.000000000 +0900
@@ -1 +1,2 @@
-<li><span>foo</span>bar</li>
+<li>
+<span>foo</span>bar</li>

Is this expected behavior?
Unintended new line breaks my html layout.

Yup, it's expected based on how Loofah works through Nokogiri. Thanks!