I have the following string: html = ‘<div id="cover" style="display: block; height: 682px"><div class="cover-desktop hidden-xs" style="background-image: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)), url(\’/site_media/covers/cover.jpg\’)"></div></div>’ And these are my options: ALLOWED_TAGS = bleach.sanitizer.ALLOWED_TAGS + [ ‘p’, ‘div’, ‘table’, ‘br’, ‘style’ ] ALLOWED_STYLES = [‘display’, ‘height’, ‘background-image’] ALLOWED_ATTRIBUTES = { ‘*’: [‘id’, ‘class’, ‘style’] } However […]
Categories
bleach stripping style that should be allowed
- Post author By Full Stack
- Post date January 24, 2021
- No Comments on bleach stripping style that should be allowed
- Tags 'background-image'] ALLOWED_ATTRIBUTES = { '*': ['id', 'style' ] ALLOWED_STYLES = ['display', 'style'] } However when running bleach.clean, "div", 0, 0.45, attributes=ALLOWED_ATTRIBUTES) Output: u'<div class="cover-desktop hidden-xs" style=, br', class, height, how can I allow any style? '*' doesn't do the trick. edit: in fact, I have the following string: html = '<div class="cover-desktop hidden-xs" style="backg, it's stripping all styles from the .cover-desktop and .cover-image (i.e. display: block)., rgba(0, styles=ALLOWED_STYLES, table, tags=ALLOWED_TAGS, the background-image style is getting stripped: cleaned_html = bleach.clean(html, url(\'/site_media/covers/cover.jpg\')">' And these are my options: ALLOWED_TAGS = bleach.sanitizer.ALLOWED_TAGS + [ 'p'