From 9e8ebbba4e5cfd6c440539ee97fa87f6c0905754 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 19 Apr 2020 13:31:45 -0700 Subject: [PATCH] Require appropriate src attribute on all captcha-related iframes. #2531 --- src/Posting/Captcha.replace.coffee | 6 +++--- src/Posting/Captcha.v2.coffee | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Posting/Captcha.replace.coffee b/src/Posting/Captcha.replace.coffee index a58864dde..42324e2a9 100644 --- a/src/Posting/Captcha.replace.coffee +++ b/src/Posting/Captcha.replace.coffee @@ -8,9 +8,9 @@ Captcha.replace = if Conf['captchaLanguage'].trim() or Conf['Captcha Fixes'] if location.hostname in ['boards.4chan.org', 'boards.4channel.org'] - $.onExists doc, '#captchaFormPart', (node) -> $.onExists node, 'iframe', Captcha.replace.iframe + $.onExists doc, '#captchaFormPart', (node) -> $.onExists node, 'iframe[src^="https://www.google.com/recaptcha/"]', Captcha.replace.iframe else - $.onExists doc, 'iframe', Captcha.replace.iframe + $.onExists doc, 'iframe[src^="https://www.google.com/recaptcha/"]', Captcha.replace.iframe noscript: -> return if not ((original = $ '#g-recaptcha') and (noscript = $ 'noscript', original.parentNode)) @@ -20,7 +20,7 @@ Captcha.replace = $.rm original insert = -> span.innerHTML = noscript.textContent - Captcha.replace.iframe $('iframe', span) + Captcha.replace.iframe $('iframe[src^="https://www.google.com/recaptcha/"]', span) if (toggle = $ '#togglePostFormLink a, #form-link') $.on toggle, 'click', insert else diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 41fcf41f4..de27a3d53 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -69,7 +69,7 @@ Captcha.v2 = if @nodes.container # XXX https://bugzilla.mozilla.org/show_bug.cgi?id=1226835 $.queueTask => - if @nodes.container and d.activeElement is @nodes.counter and (iframe = $ 'iframe', @nodes.container) + if @nodes.container and d.activeElement is @nodes.counter and (iframe = $ 'iframe[src^="https://www.google.com/recaptcha/"]', @nodes.container) iframe.focus() QR.focus() # Event handler not fired in Firefox return @@ -120,7 +120,7 @@ Captcha.v2 = afterSetup: (mutations) -> for mutation in mutations for node in mutation.addedNodes - @setupIFrame iframe if (iframe = $.x './descendant-or-self::iframe', node) + @setupIFrame iframe if (iframe = $.x './descendant-or-self::iframe[starts-with(@src, "https://www.google.com/recaptcha/")]', node) @setupTextArea textarea if (textarea = $.x './descendant-or-self::textarea', node) return