No longer accept arbitrary properties in $.ajax; make it clear what we support.
This commit is contained in:
parent
7db3041504
commit
71896af275
@ -83,7 +83,6 @@ DeleteLink =
|
|||||||
responseType: 'document'
|
responseType: 'document'
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
onloadend: -> DeleteLink.load link, post, fileOnly, @response
|
onloadend: -> DeleteLink.load link, post, fileOnly, @response
|
||||||
,
|
|
||||||
form: $.formData form
|
form: $.formData form
|
||||||
|
|
||||||
load: (link, post, fileOnly, resDoc) ->
|
load: (link, post, fileOnly, resDoc) ->
|
||||||
|
|||||||
@ -76,13 +76,13 @@ Report =
|
|||||||
results = []
|
results = []
|
||||||
for [name, url] in urls
|
for [name, url] in urls
|
||||||
do (name, url) ->
|
do (name, url) ->
|
||||||
$.ajax url,
|
$.ajax url, {
|
||||||
onloadend: ->
|
onloadend: ->
|
||||||
results.push [name, @response or {error: ''}]
|
results.push [name, @response or {error: ''}]
|
||||||
if results.length is urls.length
|
if results.length is urls.length
|
||||||
cb results
|
cb results
|
||||||
,
|
form
|
||||||
{form}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
archiveResults: (results) ->
|
archiveResults: (results) ->
|
||||||
|
|||||||
@ -708,10 +708,9 @@ QR =
|
|||||||
responseType: 'document'
|
responseType: 'document'
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
onloadend: QR.response
|
onloadend: QR.response
|
||||||
extra =
|
|
||||||
form: $.formData formData
|
form: $.formData formData
|
||||||
if Conf['Show Upload Progress']
|
if Conf['Show Upload Progress']
|
||||||
extra.onprogress = (e) ->
|
options.onprogress = (e) ->
|
||||||
if e.loaded < e.total
|
if e.loaded < e.total
|
||||||
# Uploading...
|
# Uploading...
|
||||||
QR.req.progress = "#{Math.round e.loaded / e.total * 100}%"
|
QR.req.progress = "#{Math.round e.loaded / e.total * 100}%"
|
||||||
@ -725,11 +724,11 @@ QR =
|
|||||||
if response?
|
if response?
|
||||||
QR.currentCaptcha = response
|
QR.currentCaptcha = response
|
||||||
if response.challenge?
|
if response.challenge?
|
||||||
extra.form.append 'recaptcha_challenge_field', response.challenge
|
options.form.append 'recaptcha_challenge_field', response.challenge
|
||||||
extra.form.append 'recaptcha_response_field', response.response
|
options.form.append 'recaptcha_response_field', response.response
|
||||||
else
|
else
|
||||||
extra.form.append 'g-recaptcha-response', response.response
|
options.form.append 'g-recaptcha-response', response.response
|
||||||
QR.req = $.ajax "https://sys.#{location.hostname.split('.')[1]}.org/#{g.BOARD}/post", options, extra
|
QR.req = $.ajax "https://sys.#{location.hostname.split('.')[1]}.org/#{g.BOARD}/post", options
|
||||||
QR.req.progress = '...'
|
QR.req.progress = '...'
|
||||||
|
|
||||||
if typeof captcha is 'function'
|
if typeof captcha is 'function'
|
||||||
@ -867,7 +866,6 @@ QR =
|
|||||||
cb()
|
cb()
|
||||||
else
|
else
|
||||||
setTimeout check, attempts * $.SECOND
|
setTimeout check, attempts * $.SECOND
|
||||||
,
|
|
||||||
type: 'HEAD'
|
type: 'HEAD'
|
||||||
check()
|
check()
|
||||||
|
|
||||||
|
|||||||
@ -46,9 +46,9 @@ $.ajax = do ->
|
|||||||
else
|
else
|
||||||
pageXHR = XMLHttpRequest
|
pageXHR = XMLHttpRequest
|
||||||
|
|
||||||
(url, options={}, extra={}) ->
|
(url, options={}) ->
|
||||||
{type, onprogress, form, headers} = extra
|
{onloadend, timeout, responseType, withCredentials, type, onprogress, form, headers} = options
|
||||||
options.responseType ?= 'json'
|
responseType ?= 'json'
|
||||||
# XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310
|
# XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310
|
||||||
url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/'
|
url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/'
|
||||||
r = new pageXHR()
|
r = new pageXHR()
|
||||||
@ -57,7 +57,7 @@ $.ajax = do ->
|
|||||||
r.open type, url, true
|
r.open type, url, true
|
||||||
for key, value of (headers or {})
|
for key, value of (headers or {})
|
||||||
r.setRequestHeader key, value
|
r.setRequestHeader key, value
|
||||||
$.extend r, options
|
$.extend r, {onloadend, timeout, responseType, withCredentials}
|
||||||
$.extend r.upload, {onprogress}
|
$.extend r.upload, {onprogress}
|
||||||
# connection error or content blocker
|
# connection error or content blocker
|
||||||
$.on r, 'error', -> (c.warn "4chan X failed to load: #{url}" unless r.status)
|
$.on r, 'error', -> (c.warn "4chan X failed to load: #{url}" unless r.status)
|
||||||
@ -72,9 +72,9 @@ $.ajax = do ->
|
|||||||
catch err
|
catch err
|
||||||
# XXX Some content blockers in Firefox (e.g. Adblock Plus and NoScript) throw an exception instead of simulating a connection error.
|
# XXX Some content blockers in Firefox (e.g. Adblock Plus and NoScript) throw an exception instead of simulating a connection error.
|
||||||
throw err unless err.result is 0x805e0006
|
throw err unless err.result is 0x805e0006
|
||||||
for event in ['error', 'loadend']
|
r.onloadend = onloadend
|
||||||
r["on#{event}"] = options["on#{event}"]
|
$.queueTask $.event, 'error', null, r
|
||||||
$.queueTask $.event, event, null, r
|
$.queueTask $.event, 'loadend', null, r
|
||||||
r
|
r
|
||||||
|
|
||||||
# Status Code 304: Not modified
|
# Status Code 304: Not modified
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user