Skip to content

Ensure book title/summary are not escaped twice #38675

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

Merged
merged 2 commits into from
Mar 24, 2025

Conversation

hamishwillee
Copy link
Collaborator

@hamishwillee hamishwillee commented Mar 17, 2025

Fix #5320

This displays the data in book detail title & summary unescaped. That's OK because the form only displays data that has already been sanitized. If we don't do this it gets sanitized on display, so we see the sanitization code we added on saving.

Demo side is:

@hamishwillee hamishwillee requested a review from a team as a code owner March 17, 2025 03:04
@hamishwillee hamishwillee requested review from pepelsbey and removed request for a team March 17, 2025 03:04
@github-actions github-actions bot added Content:Learn Learning area docs size/s [PR only] 6-50 LoC changed labels Mar 17, 2025
Copy link
Contributor

github-actions bot commented Mar 17, 2025

@Josh-Cena
Copy link
Member

This is the demo side fix to #5320

Is the other side of the fix coming up? We should have at least one PR that automatically closes the issue which usually is the content PR.

Also, does escaping the backing string do more things than preventing HTML injection? Does it also prevent SQL injection, considering we aren't even writing raw SQL? If its only goal is to prevent HTML injection, then that should be done in the templating layer, because as you have realized the current way already causes bugs with re-updating.

@hamishwillee
Copy link
Collaborator Author

Yeah - #38675

I linked in the middle at #5320

@Josh-Cena
Copy link
Member

Oh yeah see it now: mdn/express-locallibrary-tutorial#305 the PR description put me off for a sec (it should be "content side" not "demo side"). I'm linking the issue to this PR.

@hamishwillee hamishwillee force-pushed the template_express_unescape branch from 7f2ee15 to 7bca06e Compare March 21, 2025 01:37
@hamishwillee hamishwillee requested a review from bsmth March 21, 2025 01:37
Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

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

Looks like a reasonable solution to me. Thank you :)

@Josh-Cena Josh-Cena merged commit 275a3c7 into mdn:main Mar 24, 2025
8 checks passed
bramus pushed a commit to bramus/mdn-content that referenced this pull request Apr 1, 2025
cssinate pushed a commit to cssinate/content that referenced this pull request Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Learn Learning area docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with "Create Book form": Summary field - textarea double-escapes quotes
3 participants