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

how to keep img tag #34

Open
ohblue opened this issue Oct 31, 2023 · 3 comments
Open

how to keep img tag #34

ohblue opened this issue Oct 31, 2023 · 3 comments

Comments

@ohblue
Copy link

ohblue commented Oct 31, 2023

I have allowed the tag by seeting

Sanitizer({
    "tags": ("img","a", "h1", "h2", "h3", "strong", "em", "p", "ul", "ol","li", "br", "sub", "sup", "hr")
})

but the tag is still being removed.

@matthiask
Copy link
Owner

Hi @ohblue

I added a test which demonstrates how you can preserve the img tag. See 74a7a59

@seamys
Copy link

seamys commented Dec 25, 2023

@matthiask No, that should not work, because you have completely overwride exists setting

@seamys
Copy link

seamys commented Dec 25, 2023

@ohblue
Trying to create a pr for fixing both iframe and img issues. but you can work this way

# Make a copy
html_settings = dict(html_sanitizer.sanitizer.DEFAULT_SETTINGS)

# Add your changes
html_settings['tags'].add('img')
html_settings['empty'].add('img')
html_settings['attributes'].update({'img': ('src', 'alt', 'title')})

sanitizer = Sanitizer(settings=html_settings)

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

No branches or pull requests

3 participants