diff options
author | Christopher Ng <chrng8@gmail.com> | 2021-10-04 21:13:22 +0000 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2021-11-08 22:21:13 +0100 |
commit | e5873a2f8d3c4b01b1a5d76e9380982393d72833 (patch) | |
tree | 75fa85bd35b4572398df48f144abb869c93d12fa /apps/comments/src/services/GetComments.js | |
parent | 18e32104ce4a5750f7316aadf9363cc780bdf750 (diff) | |
download | nextcloud-server-e5873a2f8d3c4b01b1a5d76e9380982393d72833.tar.gz nextcloud-server-e5873a2f8d3c4b01b1a5d76e9380982393d72833.zip |
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>
Diffstat (limited to 'apps/comments/src/services/GetComments.js')
-rw-r--r-- | apps/comments/src/services/GetComments.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/apps/comments/src/services/GetComments.js b/apps/comments/src/services/GetComments.js index a917b123a48..b6b2db57217 100644 --- a/apps/comments/src/services/GetComments.js +++ b/apps/comments/src/services/GetComments.js @@ -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 +} |