forked from MarseyWorld/MarseyWorld
fix this https://rdrama.net/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/4738827#context
parent
1977941bb3
commit
dc59bfc5a5
|
@ -119,7 +119,7 @@ imgur_regex = re.compile(f'(https:\/\/i\.imgur\.com\/[a-z0-9]+)\.({image_regex_e
|
||||||
|
|
||||||
giphy_regex = re.compile('(https:\/\/media\.giphy\.com\/media\/[a-z0-9]+\/giphy)\.gif', flags=re.I|re.A)
|
giphy_regex = re.compile('(https:\/\/media\.giphy\.com\/media\/[a-z0-9]+\/giphy)\.gif', flags=re.I|re.A)
|
||||||
|
|
||||||
youtube_regex = re.compile('((<p>|<img)[^<]*)(https:\/\/youtube\.com\/watch\?[\w\-.#&/=?@%+]{7,})', flags=re.I|re.A)
|
youtube_regex = re.compile('<a href="(https:\/\/youtube\.com\/watch\?[\w\-.#&/=?@%+]{7,}).*?<\/a>' + NOT_IN_CODE_OR_LINKS, flags=re.I|re.A)
|
||||||
yt_id_regex = re.compile('[\w\-]{5,20}', flags=re.A)
|
yt_id_regex = re.compile('[\w\-]{5,20}', flags=re.A)
|
||||||
|
|
||||||
rumble_regex = re.compile('https://rumble\.com/embed/([a-zA-Z0-9]*)/\?pub=([a-zA-Z0-9]*)',flags=re.I|re.A)
|
rumble_regex = re.compile('https://rumble\.com/embed/([a-zA-Z0-9]*)/\?pub=([a-zA-Z0-9]*)',flags=re.I|re.A)
|
||||||
|
|
|
@ -501,15 +501,6 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
|
||||||
|
|
||||||
sanitized = sanitized.replace('&','&')
|
sanitized = sanitized.replace('&','&')
|
||||||
|
|
||||||
captured = []
|
|
||||||
for i in youtube_regex.finditer(sanitized):
|
|
||||||
if i.group(0) in captured: continue
|
|
||||||
captured.append(i.group(0))
|
|
||||||
|
|
||||||
html = handle_youtube_links(i.group(3))
|
|
||||||
if html:
|
|
||||||
sanitized = sanitized.replace(i.group(0), i.group(1) + html)
|
|
||||||
|
|
||||||
sanitized = video_sub_regex.sub(r'<p class="resizable"><video controls preload="none" src="\1"></video></p>', sanitized)
|
sanitized = video_sub_regex.sub(r'<p class="resizable"><video controls preload="none" src="\1"></video></p>', sanitized)
|
||||||
sanitized = audio_sub_regex.sub(r'<audio controls preload="none" src="\1"></audio>', sanitized)
|
sanitized = audio_sub_regex.sub(r'<audio controls preload="none" src="\1"></audio>', sanitized)
|
||||||
|
|
||||||
|
@ -601,9 +592,17 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
|
||||||
link["target"] = "_blank"
|
link["target"] = "_blank"
|
||||||
link["rel"] = "nofollow noopener"
|
link["rel"] = "nofollow noopener"
|
||||||
|
|
||||||
|
|
||||||
sanitized = str(soup).replace('<html><body>','').replace('</body></html>','').replace('/>','>')
|
sanitized = str(soup).replace('<html><body>','').replace('</body></html>','').replace('/>','>')
|
||||||
|
|
||||||
|
captured = []
|
||||||
|
for i in youtube_regex.finditer(sanitized):
|
||||||
|
if i.group(0) in captured: continue
|
||||||
|
captured.append(i.group(0))
|
||||||
|
|
||||||
|
html = handle_youtube_links(i.group(1))
|
||||||
|
if html:
|
||||||
|
sanitized = sanitized.replace(i.group(0), html)
|
||||||
|
|
||||||
if '<pre>' not in sanitized and blackjack != "rules":
|
if '<pre>' not in sanitized and blackjack != "rules":
|
||||||
sanitized = sanitized.replace('\n','')
|
sanitized = sanitized.replace('\n','')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue