Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2022-11-08 02:27:15 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2022-11-10 15:50:52 +0300
commit5442f8efd6c9cb2b75ccc077bee9a619084194c7 (patch)
tree3452b9af98c3cf44bb777b6c63835a53f1dff9b8
parent924c090f07c85b603416572a1e5533b4c8de6c0d (diff)
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>
-rw-r--r--apps/comments/src/services/NewComment.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/apps/comments/src/services/NewComment.js b/apps/comments/src/services/NewComment.js
index eaf08cc10b9..27d227ed656 100644
--- a/apps/comments/src/services/NewComment.js
+++ b/apps/comments/src/services/NewComment.js
@@ -22,6 +22,7 @@
import { getCurrentUser } from '@nextcloud/auth'
import { getRootPath } from '../utils/davUtils'
+import { decodeHtmlEntities } from '../utils/decodeHtmlEntities'
import axios from '@nextcloud/axios'
import client from './DavClient'
@@ -55,5 +56,12 @@ export default async function(commentsType, ressourceId, message) {
details: true,
})
+ const props = comment.data.props
+ // Decode twice to handle potentially double-encoded entities
+ // FIXME Remove this once https://github.com/nextcloud/server/issues/29306
+ // is resolved
+ props.actorDisplayName = decodeHtmlEntities(props.actorDisplayName, 2)
+ props.message = decodeHtmlEntities(props.message, 2)
+
return comment.data
}