Skip to content

Docs: Fix escaping in HTML escaping example #5742

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

Open
wants to merge 7 commits into
base: stable
Choose a base branch
from

Conversation

Badhreesh
Copy link

@Badhreesh Badhreesh commented May 21, 2025

The code in the Quickstart's HTML Escaping section does not render name=<script>alert("bad")</script> to text because the slash in </script> gets interpreted as a trailing slash, leading to a 404.

Getting the name as a query parameter instead allows:

  1. the script tag to be rendered as text if HTML escaping is done
  2. the alert in the script tag to be executed if HTML escaping is not done.

@Badhreesh
Copy link
Author

Badhreesh commented May 21, 2025

@davidism, I realized that for docs changes I should've made the PR from the stable branch. I've closed the previous PR and made a new one pointing to the correct branch.

@davidism
Copy link
Member

I wonder if there's a way to demonstrate the issue using the existing url, rather than changing to the path type, which doesn't really make sense in this context. Either using something like <img> that doesn't require a closing tag, or taking the argument from request.args?

@Badhreesh
Copy link
Author

I wonder if there's a way to demonstrate the issue using the existing url, rather than changing to the path type, which doesn't really make sense in this context. Either using something like <img> that doesn't require a closing tag, or taking the argument from request.args?

I agree. Since the emphasis on escaping is to prevent the execution of scripts, I went ahead with using request.args to ensure correct demonstration of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants