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 the escapeAttribute function using HTML entities instead of backslash escapes #6206

Conversation

letydoesstuff
Copy link
Contributor

@letydoesstuff letydoesstuff commented Feb 5, 2024

Description

HTML attributes used for rendering embeds break if they contain double quote characters. The commit edc6952 attempts to address this issue using backslash escapes. However, this does not work because inserting backslash characters does not actually escape the problematic double quote character from the HTML value.

The current, resultant behavior is that the truncated description gets cut short early after the first backslash character, terminating where the double quote character would be.

improperescape

The expected behavior is for the truncated description to render with the embed in its entirety.

properescape.

This would require for double quote characters to be replaced with the " HTML entity instead of being backslash-escaped, which is what this PR does.

Related issues

#6205

Has this been tested?

  • 👍 yes, I added tests to the test suite
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because this PR does not update server code
  • 🙋 no, because I need help

Sorry, I'm not sure which box I should check here. I'm really new to GitHub and any kind of code dev in general if I'm being quite honest, and parts of the testing guide still go over my head.

I have tested this fix on my own personal PeerTube server. My fix can be confirmed by checking the HTML meta tags for this video and then posting that link somewhere that would generate an embed that contains the truncated description. The example I used in my screenshots is Discord.

A video on any other PeerTube server with a similar description to mine would have its embed's description terminate early at the first double quote character.

@Chocobozzz Chocobozzz force-pushed the upstream-pr/fix-escapeAttribute-function branch from 7d633b1 to 6e1ab8c Compare February 15, 2024 13:39
@Chocobozzz
Copy link
Owner

Thanks! I adapted the tests with your fix :)

@Chocobozzz Chocobozzz merged commit c4b0398 into Chocobozzz:develop Feb 15, 2024
12 checks passed
@Chocobozzz Chocobozzz added the Type: Bug 🐛 Confirmed bug, at least replicated once by another contributor label Feb 15, 2024
@letydoesstuff letydoesstuff deleted the upstream-pr/fix-escapeAttribute-function branch February 23, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Confirmed bug, at least replicated once by another contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants