Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Remove attempt at fixing the (null) bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Jan 15, 2020
1 parent fa122d3 commit 21aebb4
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 43 deletions.
11 changes: 1 addition & 10 deletions java/src/name/fraser/neil/plaintext/diff_match_patch.java
Original file line number Diff line number Diff line change
Expand Up @@ -1576,16 +1576,7 @@ private String decodeURI(String text) throws IllegalArgumentException {
throw new IllegalArgumentException();
}

// some objective-c versions of the library produced patches with
// (null) in the place where surrogates were split across diff
// boundaries. if we leave those in we'll be stuck with a
// high-surrogate (null) low-surrogate pattern that will break
// deeper in the library or consuming application. we'll "fix"
// these by dropping the (null) and re-joining the surrogate halves
return decoded.toString().replaceAll(
"([\\uD800-\\uDBFF])\\(null\\)([\\uDC00-\\uDFFF])",
"$1$2"
);
return decoded.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,6 @@ public static void testDiffDelta() {
dmp.diff_toDelta(dmp.diff_fromDelta("\ud83c\udd70", "=1\t-1\t+%ED%B5%B1"))
);

assertEquals(
"diff_fromDelta: Invalid diff from objective-c with (null) string",
diffList(new Diff(INSERT, "\ud83c\udd70")),
dmp.diff_fromDelta("", "+%ED%A0%BC%28null%29%ED%B5%B0")
);

// Verify pool of unchanged characters.
diffs = diffList(new Diff(INSERT, "A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; / ? : @ & = + $ , # "));
String text2 = dmp.diff_text2(diffs);
Expand Down
10 changes: 5 additions & 5 deletions javascript/diff_match_patch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions javascript/diff_match_patch_uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,6 @@ diff_match_patch.prototype.diff_toDelta = function(diffs) {
var text = [];
var lastEnd;
for (var x = 0; x < diffs.length; x++) {

var thisDiff = diffs[x];
var thisTop = thisDiff[1][0];
var thisEnd = thisDiff[1][thisDiff[1].length - 1];
Expand Down Expand Up @@ -1512,13 +1511,7 @@ diff_match_patch.prototype.decodeURI = function(text) {
throw new URIError('URI malformed');
}

// some objective-c versions of the library produced patches with
// (null) in the place where surrogates were split across diff
// boundaries. if we leave those in we'll be stuck with a
// high-surrogate (null) low-surrogate pattern that will break
// deeper in the library or consuming application. we'll "fix"
// these by dropping the (null) and re-joining the surrogate halves
return decoded.replace(/([\uD800-\uDBFF])\(null\)([\uDC00-\uDFFF])/g, "$1$2");
return decoded;
}
};

Expand Down
11 changes: 1 addition & 10 deletions javascript/tests/diff_match_patch_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ function testDiffDelta() {

for(let i = 0; i < 1000; i++) {
newText = applyRandomTextEdit(originalText);
dmp.patch_toText(dmp.patch_make(originalText, newText));
dmp.diff_toDelta(dmp.diff_main(originalText, newText));
}
})();

Expand Down Expand Up @@ -605,15 +605,6 @@ function testDiffDelta() {
assertEquals('Swap surrogate pair', 'crashed');
}

try {
assertEquivalent(
dmp.diff_fromDelta('', '+%ED%A0%BC%28null%29%ED%B5%B0'),
[[DIFF_INSERT, '\ud83c\udd70']]
);
} catch ( e ) {
assertEquals('Invalid diff from objective-c with (null) string' );
}

// Empty diff groups
assertEquivalent(
dmp.diff_toDelta([[DIFF_EQUAL, 'abcdef'], [DIFF_DELETE, ''], [DIFF_INSERT, 'ghijk']]),
Expand Down
4 changes: 0 additions & 4 deletions objectivec/Tests/DiffMatchPatchTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,6 @@ - (void)test_diff_deltaTest {
[Diff diffWithOperation:DIFF_INSERT andText:[NSString stringWithFormat:@"%C", 0xdd71]],
nil])]);

// Invalid diff from objective-c with (null) string
XCTAssertEqualObjects([dmp diff_fromDeltaWithText:@"" andDelta:@"+%ED%A0%BC%28null%29%ED%B5%B0" error:nil],
([NSMutableArray arrayWithObjects:[Diff diffWithOperation:DIFF_INSERT andText:@"🅰"],nil]));

// Verify pool of unchanged characters.
diffs = [NSMutableArray arrayWithObject:
[Diff diffWithOperation:DIFF_INSERT andText:@"A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; / ? : @ & = + $ , # "]];
Expand Down

0 comments on commit 21aebb4

Please sign in to comment.