mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Fix HTML entity rendering in file comments sidebar
Signed-off-by: Christopher Ng <chrng8@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
parent
18e32104ce
commit
e5873a2f8d
3 changed files with 51 additions and 34 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -74,6 +74,23 @@ function processMultistatus(result, isDetailed = false) {
|
|||
const {
|
||||
propstat: { prop: props },
|
||||
} = item
|
||||
return prepareFileFromProps(props, props.id.toString(), isDetailed)
|
||||
// Decode HTML entities
|
||||
const decodedProps = {
|
||||
...props,
|
||||
// Decode twice to handle potentially double-encoded entities
|
||||
// FIXME Remove this once https://github.com/nextcloud/server/issues/29306 is resolved
|
||||
actorDisplayName: decodeHtmlEntities(props.actorDisplayName, 2),
|
||||
message: decodeHtmlEntities(props.message, 2),
|
||||
}
|
||||
return prepareFileFromProps(decodedProps, decodedProps.id.toString(), isDetailed)
|
||||
})
|
||||
}
|
||||
|
||||
function decodeHtmlEntities(value, passes = 1) {
|
||||
const parser = new DOMParser()
|
||||
let decoded = value
|
||||
for (let i = 0; i < passes; i++) {
|
||||
decoded = parser.parseFromString(decoded, 'text/html').documentElement.textContent
|
||||
}
|
||||
return decoded
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue