Skip to content

Commit

Permalink
Fix HTML entities not decoded in comment just added
Browse files Browse the repository at this point in the history
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, "&" 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>
  • Loading branch information
danxuliu authored and backportbot-nextcloud[bot] committed Nov 11, 2022
1 parent 16606e4 commit 36d539f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/comments/src/services/NewComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
}

0 comments on commit 36d539f

Please sign in to comment.