0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-09 11:32:39 +00:00

Fix for diff patching using encodeURI

This commit is contained in:
G.Ambatte
2025-07-19 14:49:02 +12:00
parent bfd14757c2
commit b87c78474d
2 changed files with 2 additions and 2 deletions

View File

@@ -266,7 +266,7 @@ const EditPage = createClass({
brew.text = brew.text.normalize('NFC'); brew.text = brew.text.normalize('NFC');
this.savedBrew.text = this.savedBrew.text.normalize('NFC'); this.savedBrew.text = this.savedBrew.text.normalize('NFC');
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1; brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
brew.patches = stringifyPatches(makePatches(this.savedBrew.text, brew.text)); brew.patches = stringifyPatches(makePatches(encodeURI(this.savedBrew.text), encodeURI(brew.text)));
brew.hash = await md5(this.savedBrew.text); brew.hash = await md5(this.savedBrew.text);
//brew.text = undefined; - Temporary parallel path //brew.text = undefined; - Temporary parallel path
brew.textBin = undefined; brew.textBin = undefined;

View File

@@ -375,7 +375,7 @@ const api = {
try { try {
const patches = parsePatch(brewFromClient.patches); const patches = parsePatch(brewFromClient.patches);
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error. // Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
const patchedResult = applyPatches(patches, brewFromServer.text, { allowExceedingIndices: true })[0]; const patchedResult = decodeURI(applyPatches(patches, encodeURI(brewFromServer.text))[0]);
if(patchedResult != brewFromClient.text) if(patchedResult != brewFromClient.text)
throw("Patches did not apply cleanly, text mismatch detected"); throw("Patches did not apply cleanly, text mismatch detected");
// brew.text = applyPatches(patches, brewFromServer.text)[0]; // brew.text = applyPatches(patches, brewFromServer.text)[0];