forked from rDrama/rDrama
dsfsdf
parent
e81215995e
commit
c56ac8e8fa
|
@ -78,13 +78,25 @@ no_images = ['b',
|
||||||
_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']}
|
||||||
|
|
||||||
|
|
||||||
def sanitize(sanitized):
|
def sanitize(sanitized, noimages=False):
|
||||||
|
|
||||||
sanitized = sanitized.replace("\ufeff", "").replace("m.youtube.com", "youtube.com")
|
sanitized = sanitized.replace("\ufeff", "").replace("m.youtube.com", "youtube.com")
|
||||||
|
|
||||||
for i in re.finditer('https://i.imgur.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized):
|
for i in re.finditer('https://i.imgur.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized):
|
||||||
sanitized = sanitized.replace(i.group(1), i.group(2) + "_d." + i.group(3) + "?maxwidth=9999")
|
sanitized = sanitized.replace(i.group(1), i.group(2) + "_d." + i.group(3) + "?maxwidth=9999")
|
||||||
|
|
||||||
|
if noimages:
|
||||||
|
sanitized = bleach.Cleaner(tags=no_images,
|
||||||
|
attributes=_allowed_attributes,
|
||||||
|
protocols=_allowed_protocols,
|
||||||
|
styles=_allowed_styles,
|
||||||
|
filters=[partial(LinkifyFilter,
|
||||||
|
skip_tags=["pre"],
|
||||||
|
parse_email=False,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
).clean(sanitized)
|
||||||
|
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'],
|
||||||
|
|
Loading…
Reference in New Issue