Require appropriate src attribute on all captcha-related iframes. #2531

This commit is contained in:
ccd0 2020-04-19 13:31:45 -07:00
parent a861c7a5b8
commit 9e8ebbba4e
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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