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

allowed_attributes settings wipes out default allowed_attributes unexpectedly. #92

Closed
tian-yan opened this issue Nov 10, 2021 · 1 comment · Fixed by #108
Closed

allowed_attributes settings wipes out default allowed_attributes unexpectedly. #92

tian-yan opened this issue Nov 10, 2021 · 1 comment · Fixed by #108
Labels
Milestone

Comments

@tian-yan
Copy link

tian-yan commented Nov 10, 2021

by default, allowed_attributes for <img> are ["src", "alt"].
When I configure my settings.py as below,

WAGTAILMARKDOWN = {
    "allowed_attributes": {"img": ["title"] 
                            },  
}

Based on the source code wagtailmarkdown/utils.py

if "allowed_attributes" in settings.WAGTAILMARKDOWN:
            bleach_kwargs["attributes"] = {
                **bleach_kwargs["attributes"],
                **settings.WAGTAILMARKDOWN["allowed_attributes"],
            }

Newly added allowed_attributes should be added on top of default allowed_attributes. However, based on my testing here, default allowed_attributes are wiped out and the resulted <img> only has attributetitle=" " now.

'<p><img title=" "></p>\n'
'<p><img title=" "></p>\n'

problem can be solved by including default allowed_attributes in the settings.py configurations.

WAGTAILMARKDOWN = {
    "allowed_attributes": {"img": ["title", "src", "alt"] 
                            },  
}

It is a minor issue, but since I experienced it, just share with the team.

@zerolab zerolab added the bug label Nov 10, 2021
@zerolab zerolab added this to the 0.8.0 milestone Dec 22, 2021
@zerolab zerolab linked a pull request Sep 18, 2022 that will close this issue
@zerolab
Copy link
Member

zerolab commented Sep 18, 2022

#108 aims to address this, and provide 2 additional settings to control how the allowed_*, as well as the extension* settings behave (default: extend. but can be replaced)

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 a pull request may close this issue.

2 participants