wagtail / wagtail

A Django content management system focused on flexibility and user experience
https://wagtail.org
BSD 3-Clause "New" or "Revised" License
18.28k stars 3.86k forks source link

RichText whitelisting of element attributes does not work for <a> tag #3140

Closed mevinbabuc closed 8 years ago

mevinbabuc commented 8 years ago

Issue Summary

RichText whitelisting of attributes of anchor tag does not work. It still strips of class or style attributes from the a tag. This prevents me from controlling the look of the anchor tag or prevents me from adding my own custom data attributes. I believe this is happening because the PageLinkHandler reconstructs the a tag by looking at the id and does not add other custom attributes that are added from the richtext editor by a custom plugin.

@hooks.register('construct_whitelister_element_rules')
def whitelister_element_rules():
    return {
        'a': attribute_rule({
            'style': True,
            'href': check_url,
            'class': True,
            'target': True
        }),
   }

Technical details

gasman commented 8 years ago

Hi @mevinbabuc - this is covered by #897.