We have strings with a backslash (\) followed by the letter n, where the diff does not display correctly on our web site.
Apparently the diffy gem when using to_s(:html) is splitting a string with a backslash (\) character followed by an n character into two lines.
irb(main):001:0> puts Diffy::Diff.new("A\\nZ", "B\\nZ").to_s(:html)
<div class="diff">
<ul>
<li class="del"><del><strong>A</strong></del></li>
<li class="del"><del>Z</del></li>
<li class="ins"><ins><strong>B</strong></ins></li>
<li class="ins"><ins>Z</ins></li>
</ul>
</div>
=> nil
irb(main):002:0> puts Diffy::Diff.new("A\\\\nZ", "B\\\\nZ").to_s(:html)
<div class="diff">
<ul>
<li class="del"><del><strong>A</strong>\</del></li>
<li class="del"><del>Z</del></li>
<li class="ins"><ins><strong>B</strong>\</ins></li>
<li class="ins"><ins>Z</ins></li>
</ul>
</div>
=> nil
When there are two backslashes and an r, diffy gets completely confused.
irb(main):003:0> puts Diffy::Diff.new("A\\\\r\\\\nZ", "B\\\\r\\\\nZ").to_s(:html)
<div class="diff">
<ul>
\</del></li>s="del"><del><strong>A</strong>\
<li class="del"><del>Z</del></li>
\</ins></li>s="ins"><ins><strong>B</strong>\
<li class="ins"><ins>Z</ins></li>
</ul>
</div>
=> nil
We have strings with a backslash (
\) followed by the lettern, where the diff does not display correctly on our web site.Apparently the diffy gem when using
to_s(:html)is splitting a string with a backslash (\) character followed by anncharacter into two lines.When there are two backslashes and an
r, diffy gets completely confused.