forked from MarseyWorld/MarseyWorld
dsffsd
parent
04c576909e
commit
7805b0cfbe
|
@ -91,31 +91,6 @@ _allowed_styles =[
|
|||
'transform'
|
||||
]
|
||||
|
||||
# # filter to make all links show domain on hover
|
||||
|
||||
# def a_modify(attrs, whatever):
|
||||
|
||||
# raw_url=attrs.get((None, "href"), None)
|
||||
# if raw_url:
|
||||
# parsed_url = urlparse(raw_url)
|
||||
|
||||
# domain = parsed_url.netloc
|
||||
# attrs[(None, "target")] = "_blank"
|
||||
# if domain and not domain.endswith(domain):
|
||||
# attrs[(None, "rel")] = "nofollow noopener noreferrer"
|
||||
|
||||
# new_url = ParseResult(scheme="https",
|
||||
# netloc=parsed_url.netloc,
|
||||
# path=parsed_url.path,
|
||||
# params=parsed_url.params,
|
||||
# query=parsed_url.query,
|
||||
# fragment=parsed_url.fragment)
|
||||
|
||||
# attrs[(None, "href")] = urlunparse(new_url)
|
||||
|
||||
# return attrs
|
||||
|
||||
|
||||
def sanitize(sanitized, noimages=False):
|
||||
|
||||
sanitized = sanitized.replace("\ufeff", "").replace("m.youtube.com", "youtube.com")
|
||||
|
@ -131,7 +106,6 @@ def sanitize(sanitized, noimages=False):
|
|||
filters=[partial(LinkifyFilter,
|
||||
skip_tags=["pre"],
|
||||
parse_email=False,
|
||||
# callbacks=[a_modify]
|
||||
)
|
||||
]
|
||||
).clean(sanitized)
|
||||
|
@ -143,7 +117,6 @@ def sanitize(sanitized, noimages=False):
|
|||
filters=[partial(LinkifyFilter,
|
||||
skip_tags=["pre"],
|
||||
parse_email=False,
|
||||
# callbacks=[a_modify]
|
||||
)
|
||||
]
|
||||
).clean(sanitized)
|
||||
|
@ -176,6 +149,9 @@ def sanitize(sanitized, noimages=False):
|
|||
#disguised link preventer
|
||||
for tag in soup.find_all("a"):
|
||||
|
||||
tag["target"] = "_blank"
|
||||
if site not in tag["href"]: tag["rel"] = "nofollow noopener noreferrer"
|
||||
|
||||
if re.match("https?://\S+", str(tag.string)):
|
||||
try:
|
||||
tag.string = tag["href"]
|
||||
|
|
Loading…
Reference in New Issue