Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_s(:html) mishandles \\n (backslash + en) #96

Open
marlinpierce opened this issue Apr 17, 2018 · 0 comments
Open

to_s(:html) mishandles \\n (backslash + en) #96

marlinpierce opened this issue Apr 17, 2018 · 0 comments

Comments

@marlinpierce
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant