Skip to content

Commit 21aebb4

Browse files
committed
Remove attempt at fixing the (null) bug
1 parent fa122d3 commit 21aebb4

File tree

6 files changed

+8
-43
lines changed

6 files changed

+8
-43
lines changed

java/src/name/fraser/neil/plaintext/diff_match_patch.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -1576,16 +1576,7 @@ private String decodeURI(String text) throws IllegalArgumentException {
15761576
throw new IllegalArgumentException();
15771577
}
15781578

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

15911582
/**

java/tests/name/fraser/neil/plaintext/diff_match_patch_test.java

-6
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,6 @@ public static void testDiffDelta() {
460460
dmp.diff_toDelta(dmp.diff_fromDelta("\ud83c\udd70", "=1\t-1\t+%ED%B5%B1"))
461461
);
462462

463-
assertEquals(
464-
"diff_fromDelta: Invalid diff from objective-c with (null) string",
465-
diffList(new Diff(INSERT, "\ud83c\udd70")),
466-
dmp.diff_fromDelta("", "+%ED%A0%BC%28null%29%ED%B5%B0")
467-
);
468-
469463
// Verify pool of unchanged characters.
470464
diffs = diffList(new Diff(INSERT, "A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; / ? : @ & = + $ , # "));
471465
String text2 = dmp.diff_text2(diffs);

javascript/diff_match_patch.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/diff_match_patch_uncompressed.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,6 @@ diff_match_patch.prototype.diff_toDelta = function(diffs) {
13611361
var text = [];
13621362
var lastEnd;
13631363
for (var x = 0; x < diffs.length; x++) {
1364-
13651364
var thisDiff = diffs[x];
13661365
var thisTop = thisDiff[1][0];
13671366
var thisEnd = thisDiff[1][thisDiff[1].length - 1];
@@ -1512,13 +1511,7 @@ diff_match_patch.prototype.decodeURI = function(text) {
15121511
throw new URIError('URI malformed');
15131512
}
15141513

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

javascript/tests/diff_match_patch_test.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ function testDiffDelta() {
546546

547547
for(let i = 0; i < 1000; i++) {
548548
newText = applyRandomTextEdit(originalText);
549-
dmp.patch_toText(dmp.patch_make(originalText, newText));
549+
dmp.diff_toDelta(dmp.diff_main(originalText, newText));
550550
}
551551
})();
552552

@@ -605,15 +605,6 @@ function testDiffDelta() {
605605
assertEquals('Swap surrogate pair', 'crashed');
606606
}
607607

608-
try {
609-
assertEquivalent(
610-
dmp.diff_fromDelta('', '+%ED%A0%BC%28null%29%ED%B5%B0'),
611-
[[DIFF_INSERT, '\ud83c\udd70']]
612-
);
613-
} catch ( e ) {
614-
assertEquals('Invalid diff from objective-c with (null) string' );
615-
}
616-
617608
// Empty diff groups
618609
assertEquivalent(
619610
dmp.diff_toDelta([[DIFF_EQUAL, 'abcdef'], [DIFF_DELETE, ''], [DIFF_INSERT, 'ghijk']]),

objectivec/Tests/DiffMatchPatchTest.m

-4
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,6 @@ - (void)test_diff_deltaTest {
814814
[Diff diffWithOperation:DIFF_INSERT andText:[NSString stringWithFormat:@"%C", 0xdd71]],
815815
nil])]);
816816

817-
// Invalid diff from objective-c with (null) string
818-
XCTAssertEqualObjects([dmp diff_fromDeltaWithText:@"" andDelta:@"+%ED%A0%BC%28null%29%ED%B5%B0" error:nil],
819-
([NSMutableArray arrayWithObjects:[Diff diffWithOperation:DIFF_INSERT andText:@"🅰"],nil]));
820-
821817
// Verify pool of unchanged characters.
822818
diffs = [NSMutableArray arrayWithObject:
823819
[Diff diffWithOperation:DIFF_INSERT andText:@"A-Z a-z 0-9 - _ . ! ~ * ' ( ) ; / ? : @ & = + $ , # "]];

0 commit comments

Comments
 (0)