Fix the escapeAttribute function using HTML entities instead of backslash escapes (#6206)

* Fix the escapeAttribute function using HTML entities instead of backslash escapes

* Fix tests

---------

Co-authored-by: Chocobozzz <me@florianbigard.com>
This commit is contained in:
Lety Does Stuff 2024-02-15 13:39:59 +00:00 committed by GitHub
parent ba3820965f
commit c4b039886e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -73,5 +73,5 @@ export function escapeHTML (stringParam: string) {
export function escapeAttribute (value: string) {
if (!value) return ''
return String(value).replace(/"/g, '\\"')
return String(value).replace(/"/g, '&quot;')
}

View File

@ -273,8 +273,8 @@ describe('Test Open Graph and Twitter cards HTML tags', function () {
const res = await makeGetRequest({ url: servers[0].url, path: '/a/root', accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(`<meta property="twitter:description" content="\\"super description\\"" />`)
expect(text).to.contain(`<meta property="og:description" content="\\"super description\\"" />`)
expect(text).to.contain(`<meta property="twitter:description" content="&quot;super description&quot;" />`)
expect(text).to.contain(`<meta property="og:description" content="&quot;super description&quot;" />`)
})
})