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

Added: setting for unescaping special chars (#46) #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

signebedi
Copy link

Based on discussion in #46. I added a default setting called "unescape_special_chars".

DEFAULT_SETTINGS = {
    ...
    "unescape_special_chars": False, # see discussion https://github.com/matthiask/html-sanitizer/issues/46
}

When true, special characters are added back to the HTML immediately before returning:

        # see discussion https://github.com/matthiask/html-sanitizer/issues/46
        if self.unescape_special_chars:
            html = ( html
                    .replace("&", "&")
                    .replace("&lt;", "<")
                    .replace("&gt;", ">")
            )

I welcome feedback. This is a minimalist change intended only to give end users the ability to retain some of the special characters that are stripped out during the sanitation process. If I have broken assumptions, or if I have missed other special characters, please feel free to make note of these and I am happy to make further changes before the code is merged.

@signebedi signebedi marked this pull request as ready for review June 14, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant