-
Notifications
You must be signed in to change notification settings - Fork 1
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
handle special characters in display of form submissions, so e.g. curly apostrophe does not show up as ' #245
Comments
This is a reasonable ask. We use markupsafe to escape all inputs across the board. This is a security feature but comes with plenty of drawbacks. This is a down-stream consequence of the escaping we implemented in #125, which makes it the default behavior to escape form data on read operations. An alternative is to add more robust HTML escaping solutions to sanitize data on writes, instead of escaping output on reads.
I also have a very basic sanitation function that we use for the documentation: def escape_unsafe_html(html_content):
"""Escapes unsafe HTML patterns in the provided content.
Args:
html_content (str): The HTML content to sanitize.
Returns:
str: The sanitized HTML content.
"""
# Dictionary of unsafe patterns and their escaped equivalents.
replacements = {
"<script": "<script",
"</script>": "</script>",
"<iframe": "<iframe",
"</iframe>": "</iframe>",
"javascript:": "javascript:",
"onerror=": "onerror=",
"onload=": "onload="
}
# Escape each unsafe pattern.
for unsafe, safe in replacements.items():
html_content = html_content.replace(unsafe, safe)
return html_content This is very basic but can be expanded if we don't want to add an entire new dependency... |
Using html-sanitize still escapes ampersands |
[bug] |
No description provided.
The text was updated successfully, but these errors were encountered: