Skip to content

Commit

Permalink
Fix HTML entity rendering in file comments sidebar
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
Signed-off-by: nextcloud-command <[email protected]>
  • Loading branch information
Pytal authored and CarlSchwan committed Nov 8, 2021
1 parent 18e3210 commit e5873a2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 34 deletions.
64 changes: 32 additions & 32 deletions apps/comments/js/comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/js/comments-app.js.map

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion apps/comments/src/services/GetComments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit e5873a2

Please sign in to comment.