Skip to content

Commit dd2a6d7

Browse files
committed
Fix HTML entities not decoded in comment just added
The XML data received from the comments endpoint has an inconsistent encoding; some entities are encoded once and others are encoded twice. When the comment list is loaded the comments are fetched using GetComments, which handles all that, and therefore shows the messages and author names as expected. However, when a new comment is posted the list is not got again; instead the new comment is loaded from the comment data returned after posting it. This is done in NewComment, which did not decode the messages nor the author names, and therefore showed, for example, "&amp;" instead of "&". To solve that now the same decoding logic used in GetComments is applied too in NewComment. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent bd355b4 commit dd2a6d7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/comments/src/services/NewComment.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import { getCurrentUser } from '@nextcloud/auth'
2424
import { getRootPath } from '../utils/davUtils'
25+
import { decodeHtmlEntities } from '../utils/decodeHtmlEntities'
2526
import axios from '@nextcloud/axios'
2627
import client from './DavClient'
2728

@@ -55,5 +56,12 @@ export default async function(commentsType, ressourceId, message) {
5556
details: true,
5657
})
5758

59+
const props = comment.data.props
60+
// Decode twice to handle potentially double-encoded entities
61+
// FIXME Remove this once https://github.com/nextcloud/server/issues/29306
62+
// is resolved
63+
props.actorDisplayName = decodeHtmlEntities(props.actorDisplayName, 2)
64+
props.message = decodeHtmlEntities(props.message, 2)
65+
5866
return comment.data
5967
}

0 commit comments

Comments
 (0)