forked from rDrama/rDrama
fix underscores inside links
parent
21dd678c2d
commit
df132627e6
|
@ -1,5 +1,6 @@
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
import regex
|
||||||
from random import choice, choices
|
from random import choice, choices
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
|
@ -193,3 +194,5 @@ def command_regex_matcher(match, upper=False):
|
||||||
reason_regex = re.compile('(/(post|comment)/[0-9]+)', flags=re.A)
|
reason_regex = re.compile('(/(post|comment)/[0-9]+)', flags=re.A)
|
||||||
|
|
||||||
discord_username_regex = re.compile("(\s|^|>).{2,32}#[0-9]{4}(?=[^0-9]|$)", flags=re.A)
|
discord_username_regex = re.compile("(\s|^|>).{2,32}#[0-9]{4}(?=[^0-9]|$)", flags=re.A)
|
||||||
|
|
||||||
|
underscore_in_link_regex = regex.compile("(?<=https:\/\/[^\s)]+)_", flags=regex.A)
|
||||||
|
|
|
@ -291,7 +291,10 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys
|
||||||
if FEATURES['MARKUP_COMMANDS']:
|
if FEATURES['MARKUP_COMMANDS']:
|
||||||
sanitized = command_regex.sub(command_regex_matcher, sanitized)
|
sanitized = command_regex.sub(command_regex_matcher, sanitized)
|
||||||
|
|
||||||
|
sanitized = underscore_in_link_regex.sub(r'\_', sanitized)
|
||||||
|
|
||||||
sanitized = markdown(sanitized)
|
sanitized = markdown(sanitized)
|
||||||
|
|
||||||
sanitized = strikethrough_regex.sub(r'\1<del>\2</del>', sanitized)
|
sanitized = strikethrough_regex.sub(r'\1<del>\2</del>', sanitized)
|
||||||
|
|
||||||
# replacing zero width characters, overlines, fake colons
|
# replacing zero width characters, overlines, fake colons
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
pip3 install regex
|
|
@ -23,6 +23,7 @@ pyotp
|
||||||
pywebpush
|
pywebpush
|
||||||
qrcode
|
qrcode
|
||||||
redis
|
redis
|
||||||
|
regex
|
||||||
requests
|
requests
|
||||||
SQLAlchemy
|
SQLAlchemy
|
||||||
tinycss2
|
tinycss2
|
||||||
|
|
Loading…
Reference in New Issue