cosmere icon indicating copy to clipboard operation
cosmere copied to clipboard

HTML alphanumeric values breaking local - remote equality check

Open DazEdword opened this issue 1 year ago • 4 comments

I've been using cosmere as part of a CICD pipeline, and experienced an unexplained issue: every time I'd be notified of changes in a document that, upon inspection, had no changes at all. This would happen in several documents, and comparing document versions in Confluence yielded no visible changes.

After tinkering and debugging, I'm positive this is due to html characters breaking the equality check here:

Line 48, src/UpdatePage.ts

function isRemoteUpdateRequired(newContent: string, confluencePage: any): boolean {
    const local = removeDynamicIds(newContent).trim().replace(/'/g, "'");
    const remote = removeDynamicIds(confluencePage.body.storage.value).trim();
    return local !== remote;
}

As you can see, the replace is only covering single quotes. However, any other HTML symbol is ignored, and as such it's interpreted as a different document, hence being re-uploaded. I've experienced this with other symbols such as &ndash;, &ldquo; and many others. Also, line breaks are showing as <br/> locally and <br /> remotely (note the whitespace).

Hopefully, a more thorough logic when comparing local and remotely will help with the issue.

DazEdword avatar Aug 25 '23 13:08 DazEdword

Hi Eduardo, thanks for the issue and thanks for all the upfront reasearch :hugs:

Was bound to happen at some point. I'm surprised I didn't run into this earlier or maybe it was because it's hard figuring out if you're in a code block or not when you're not actually inside a parser. Maybe different Confluence versions. I'll try to figure out how to do this properly. I'll write the tests and maybe you can have a look if I missed some test cases.

mihaeu avatar Aug 25 '23 14:08 mihaeu

No problem, happy to contribute! Feel free to add me as a reviewer when the time comes :+1: .

DazEdword avatar Aug 25 '23 14:08 DazEdword

Hi again @mihaeu! There's a chance that my employer can allocate some time for me to contribute to the project if you'd like to have support with this issue. Let me know if that's the case, if you prefer you can reach out via the site in my profile :wave:

DazEdword avatar Aug 28 '23 13:08 DazEdword

Sounds amazing, will do :+1:

mihaeu avatar Aug 29 '23 09:08 mihaeu