0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 17:52:47 +00:00

Merge pull request #4311 from dbolack-ab/md5Fix

Normalize strings before running MD5s
This commit is contained in:
Trevor Buckner
2025-07-09 22:40:15 -04:00
committed by GitHub
3 changed files with 11 additions and 8 deletions

View File

@@ -260,6 +260,8 @@ const EditPage = createClass({
//Prepare content to send to server //Prepare content to send to server
const brew = { ...this.state.brew }; const brew = { ...this.state.brew };
brew.text = brew.text.normalize();
this.savedBrew.text = this.savedBrew.text.normalize();
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(this.savedBrew.text, brew.text));
brew.hash = await md5(this.savedBrew.text); brew.hash = await md5(this.savedBrew.text);

View File

@@ -72,7 +72,7 @@
"lines": 50 "lines": 50
}, },
"server/homebrew.api.js": { "server/homebrew.api.js": {
"statements": 70, "statements": 69,
"branches": 50, "branches": 50,
"functions": 65, "functions": 65,
"lines": 70 "lines": 70

View File

@@ -341,6 +341,7 @@ const api = {
const brewFromServer = req.brew; const brewFromServer = req.brew;
splitTextStyleAndMetadata(brewFromServer); splitTextStyleAndMetadata(brewFromServer);
brewFromServer.text = brewFromServer.text.normalize();
brewFromServer.hash = await md5(brewFromServer.text); brewFromServer.hash = await md5(brewFromServer.text);
if((brewFromServer?.version !== brewFromClient?.version) || (brewFromServer?.hash !== brewFromClient?.hash)) { if((brewFromServer?.version !== brewFromClient?.version) || (brewFromServer?.hash !== brewFromClient?.hash)) {