diff --git a/files/assets/js/core.js b/files/assets/js/core.js index bd2a494ce..2acc7e169 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -255,7 +255,7 @@ function bs_trigger(e) { } }) - if (typeof update_speed_emoji_modal != 'undefined') { + if (typeof update_speed_emoji_modal == 'function') { let forms = e.querySelectorAll("textarea, .allow-emojis"); forms.forEach(i => { let pseudo_div = document.createElement("div"); @@ -266,6 +266,9 @@ function bs_trigger(e) { i.addEventListener('keydown', speed_carot_navigate, false); }); } + + if (typeof link_trigger === "function") + link_trigger(e); } var bsTriggerOnReady = function() { diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index 701ca6979..fbd0db108 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -98,9 +98,9 @@ def notify_mentions(send_to, mentions, mention_str='site mention'): text = sanitize(m['text'], golden=False) notif_text = ( f'

New {mention_str} by /u/{author}

' + f'rel="nofollow noopener">/u/{author}

' f'

' + 'rel="nofollow noopener">' f'https://old.reddit.com{permalink}?context=89

' f'{text}' ) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 8eb095945..fe2c10858 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -63,7 +63,6 @@ def allowed_attributes(tag, name, value): if name == 'href' and '\\' not in value and 'xn--' not in value: return True if name == 'rel' and value == 'nofollow noopener': return True - if name == 'target' and value == '_blank': return True return False if tag == 'img': @@ -145,8 +144,7 @@ def callback(attrs, new=False): del attrs[(None, "href")] # Make unclickable and reset harmful payload return attrs - if not href.startswith('/') and not href.startswith(f'{SITE_FULL}/'): - attrs[(None, "target")] = "_blank" + if not is_site_url(href): attrs[(None, "rel")] = "nofollow noopener" return attrs @@ -271,7 +269,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys # replacing zero width characters, overlines, fake colons sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\u033f","").replace("\u0589", ":") - sanitized = reddit_regex.sub(r'\1/\2', sanitized) + sanitized = reddit_regex.sub(r'\1/\2', sanitized) sanitized = sub_regex.sub(r'\1/\2', sanitized) v = getattr(g, 'v', None) @@ -298,7 +296,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys for tag in soup.find_all("img"): if tag.get("src") and not tag["src"].startswith('/pp/'): if not is_safe_url(tag["src"]): - a = soup.new_tag("a", href=tag["src"], rel="nofollow noopener", target="_blank") + a = soup.new_tag("a", href=tag["src"], rel="nofollow noopener") a.string = tag["src"] tag.replace_with(a) continue @@ -312,7 +310,6 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys a = soup.new_tag("a", href=tag["data-src"]) if not is_site_url(a["href"]): a["rel"] = "nofollow noopener" - a["target"] = "_blank" tag = tag.replace_with(a) a.append(tag) diff --git a/files/routes/votes.py b/files/routes/votes.py index a3a603e4b..6bfcfb814 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -153,7 +153,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): elif target.sub and target.sub not in UNNERFED_HOLES: mul = 0.7 elif not target.sub and target.body_html and target.author.id not in BOOSTED_USERS_EXCLUDED: - x = target.body_html.count('" target="_blank" rel="nofollow noopener">') + x = target.body_html.count(' - Unable to load image + Unable to load image {% endif %} @@ -103,7 +103,7 @@ {% endif %} {% if p.realurl(v) and not v_forbid_deleted %}

- + {% if p.club %}{{CC}}{% endif %} {% if p.flair %}{{p.flair | safe}}{% endif %} {{p.realtitle(v) | safe}} @@ -121,7 +121,7 @@
{% if p.realurl(v) %} {% if not p.embed_url and not p.is_image %} - +
{{p.realurl(v)}} @@ -149,7 +149,7 @@ {% if p.is_image %}
diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 1b8ff76ff..fd91adf90 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -98,7 +98,7 @@ post thumnail {% else %} - + post thumnail diff --git a/files/templates/util/html_head.html b/files/templates/util/html_head.html index 67d20b0e4..ffb19a049 100644 --- a/files/templates/util/html_head.html +++ b/files/templates/util/html_head.html @@ -11,6 +11,26 @@ {% macro javascript() %} + + {% if not v or v.newtabexternal %} + + {% endif %} + {% endmacro %} {% macro page_meta(title=none) %}