Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTML entities not decoded in comment just added #35054

Merged
merged 3 commits into from
Nov 10, 2022

Conversation

danxuliu
Copy link
Member

@danxuliu danxuliu commented Nov 9, 2022

Follow up to #29029

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.

@Pytal I extracted decodeHtmlEntities to its own file and I assigned the copyright of that file to you, as you added the original function. I hope that is fine :-)

How to test

  • Set the display name of the user to John "The Hangman" Ruth
  • Open the Files app
  • Show the sidebar for any file
  • Open the Comments tab
  • Send a new comment with text < & >

Result with this pull request

The text of the comment just added is < & >, and it was sent by John "The Hangman" Ruth

Result without this pull request

The text of the comment just added is &amp;lt; &amp; &amp;gt;, and it was sent by John &quot;The Hangman&quot; Ruth; if the page is reloaded and the Comments tab is shown again now the message has the expected author and text

@danxuliu danxuliu added this to the Nextcloud 26 milestone Nov 9, 2022
@danxuliu danxuliu requested review from skjnldsv, Pytal, a team and szaimen and removed request for a team November 9, 2022 12:55
@danxuliu
Copy link
Member Author

danxuliu commented Nov 9, 2022

/backport to stable25

@danxuliu
Copy link
Member Author

danxuliu commented Nov 9, 2022

/backport to stable24

@danxuliu
Copy link
Member Author

danxuliu commented Nov 9, 2022

/backport to stable23

@danxuliu
Copy link
Member Author

danxuliu commented Nov 9, 2022

/compile /

Copy link
Member

@Pytal Pytal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the named export suggestion :)

apps/comments/src/utils/decodeHtmlEntities.js Outdated Show resolved Hide resolved
apps/comments/src/services/NewComment.js Outdated Show resolved Hide resolved
apps/comments/src/services/GetComments.js Outdated Show resolved Hide resolved
This will make possible to use it from files other than
"GetComments.js".

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
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>
@danxuliu danxuliu force-pushed the fix-html-entities-not-decoded-in-comment-just-added branch from 1b70a7e to 4fe5b9a Compare November 10, 2022 12:52
@danxuliu
Copy link
Member Author

/compile amend /

@danxuliu
Copy link
Member Author

Other than the named export suggestion :)

Done :-)

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@nextcloud-command nextcloud-command force-pushed the fix-html-entities-not-decoded-in-comment-just-added branch from 4fe5b9a to 99b1d00 Compare November 10, 2022 13:02
Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐘

@szaimen szaimen added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Nov 10, 2022
@Pytal Pytal merged commit 66c33fd into master Nov 10, 2022
@Pytal Pytal deleted the fix-html-entities-not-decoded-in-comment-just-added branch November 10, 2022 17:10
@danxuliu
Copy link
Member Author

/backport to stable24

@danxuliu
Copy link
Member Author

/backport to stable23

@backportbot-nextcloud
Copy link

The backport to stable23 failed. Please do this backport manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug feature: comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants