Skip to content

Commit e5873a2

Browse files
PytalCarlSchwan
authored andcommitted
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>
1 parent 18e3210 commit e5873a2

3 files changed

Lines changed: 51 additions & 34 deletions

File tree

apps/comments/js/comments-app.js

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/comments/js/comments-app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/comments/src/services/GetComments.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@ function processMultistatus(result, isDetailed = false) {
7474
const {
7575
propstat: { prop: props },
7676
} = item
77-
return prepareFileFromProps(props, props.id.toString(), isDetailed)
77+
// Decode HTML entities
78+
const decodedProps = {
79+
...props,
80+
// Decode twice to handle potentially double-encoded entities
81+
// FIXME Remove this once https://github.com/nextcloud/server/issues/29306 is resolved
82+
actorDisplayName: decodeHtmlEntities(props.actorDisplayName, 2),
83+
message: decodeHtmlEntities(props.message, 2),
84+
}
85+
return prepareFileFromProps(decodedProps, decodedProps.id.toString(), isDetailed)
7886
})
7987
}
88+
89+
function decodeHtmlEntities(value, passes = 1) {
90+
const parser = new DOMParser()
91+
let decoded = value
92+
for (let i = 0; i < passes; i++) {
93+
decoded = parser.parseFromString(decoded, 'text/html').documentElement.textContent
94+
}
95+
return decoded
96+
}

0 commit comments

Comments
 (0)