forked from rDrama/rDrama
dfsfsd
parent
35203a47d2
commit
05b6b8a0ea
|
@ -8,7 +8,7 @@ import re
|
||||||
|
|
||||||
site = environ.get("DOMAIN").strip()
|
site = environ.get("DOMAIN").strip()
|
||||||
|
|
||||||
_allowed_tags = tags = ['b',
|
allowed_tags = tags = ['b',
|
||||||
'blockquote',
|
'blockquote',
|
||||||
'br',
|
'br',
|
||||||
'code',
|
'code',
|
||||||
|
@ -75,8 +75,11 @@ no_images = ['b',
|
||||||
'span',
|
'span',
|
||||||
]
|
]
|
||||||
|
|
||||||
_allowed_attributes = {'*': ['href', 'style', 'src', 'class', 'title', 'rel', 'data-bs-original-name', 'direction']}
|
allowed_attributes = {'*': ['href', 'style', 'src', 'class', 'title', 'rel', 'data-bs-original-name', 'direction']}
|
||||||
|
|
||||||
|
allowed_protocols = ['http', 'https']
|
||||||
|
|
||||||
|
allowed_styles =['color', 'font-weight', 'transform', '-webkit-transform']
|
||||||
|
|
||||||
def sanitize(sanitized, noimages=False):
|
def sanitize(sanitized, noimages=False):
|
||||||
|
|
||||||
|
@ -87,9 +90,9 @@ def sanitize(sanitized, noimages=False):
|
||||||
|
|
||||||
if noimages:
|
if noimages:
|
||||||
sanitized = bleach.Cleaner(tags=no_images,
|
sanitized = bleach.Cleaner(tags=no_images,
|
||||||
attributes=_allowed_attributes,
|
attributes=allowed_attributes,
|
||||||
protocols=_allowed_protocols,
|
protocols=allowed_protocols,
|
||||||
styles=_allowed_styles,
|
styles=allowed_styles,
|
||||||
filters=[partial(LinkifyFilter,
|
filters=[partial(LinkifyFilter,
|
||||||
skip_tags=["pre"],
|
skip_tags=["pre"],
|
||||||
parse_email=False,
|
parse_email=False,
|
||||||
|
@ -97,8 +100,8 @@ def sanitize(sanitized, noimages=False):
|
||||||
]
|
]
|
||||||
).clean(sanitized)
|
).clean(sanitized)
|
||||||
else:
|
else:
|
||||||
sanitized = bleach.Cleaner(tags=_allowed_tags,
|
sanitized = bleach.Cleaner(tags=allowed_tags,
|
||||||
attributes=_allowed_attributes,
|
attributes=allowed_attributes,
|
||||||
protocols=['http', 'https'],
|
protocols=['http', 'https'],
|
||||||
styles=['color','font-weight','transform','-webkit-transform'],
|
styles=['color','font-weight','transform','-webkit-transform'],
|
||||||
filters=[partial(LinkifyFilter,
|
filters=[partial(LinkifyFilter,
|
||||||
|
|
Loading…
Reference in New Issue