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 <chrng8@gmail.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
Pytal committed Oct 21, 2021
1 parent 5d9474d commit e6abd38
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 617 deletions.
615 changes: 0 additions & 615 deletions apps/comments/js/comments-app.js

This file was deleted.

1 change: 0 additions & 1 deletion apps/comments/js/comments-app.js.map

This file was deleted.

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 e6abd38

Please sign in to comment.