curran / curran/google-diff-match-patch

[JS] patch_fromText breaks on IE8

Open
#74 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
Python
Stars
17
Forks
2
PR merge metrics
No merged PRs in 30d

Description

```
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.