Dana-Ferguson / google-diff-match-patch

Automatically exported from code.google.com/p/google-diff-match-patch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[JS] patch_fromText breaks on IE8

GoogleCodeExporter opened this issue · comments

What steps will reproduce the problem?
1. Performs patch_fromText on a diff string.
2. The diff string is:

var diffString = "@@ -3,14 +3,12 @@\n mple\n-st\n  co\n-nt\n+mm\n ent\n"

3. var patches = dmp.patch_fromText(diffString);

What is the expected output? What do you see instead?

The array of patches object. But I see nothing, and IE8 gives an error of 
"Invalid patch string: @@ -3,14 +3,12 @@"

What version of the product are you using? On what operating system?
I'm using diff_match_patch_20120106.zip, on Windows XP with IE8.

Please provide any additional information below.

I traced down to the issue that IE8 or below appends \r into the string. 
Therefore, on line 2062 of the uncompressed version, when only splitting on \n, 
it will fail and thus can't match with the regex for patchHeader.

I modified line 2062 to the below and it works:

var text = textline.split(/\r\n|\r|\n/);

Original issue reported on code.google.com by ese...@gmail.com on 21 Jun 2012 at 3:17