Open
Description
The following code:
const DiffMatchPatch = require('diff-match-patch');
const dmp = new DiffMatchPatch();
const patchText = dmp.patch_toText(dmp.patch_make('', 'π¨βπ¦° π¨πΏβπ¦° π¨β𦱠π¨πΏβ𦱠π¦ΉπΏββοΈ'));
const patchObj = dmp.patch_fromText(patchText);
const [patchedText] = dmp.patch_apply(patchObj, '');
dmp.patch_toText(dmp.patch_make(patchedText, 'πΎ π π π
π π π π'));
Will throw an error "URI Malformed" at this line. That's often the problem when using encodeURI on arbitrary data (the md5 package has the same problem) but in that case as far as I can see the inputs are valid UTF-8.
I think either patch_make
or patch_apply
generates invalid text.
But also I'm wondering why is encodeURI needed in this lib? Wouldn't a simple escape/unescape of specific reserved characters be enough?
Metadata
Metadata
Assignees
Labels
No labels