Fix Firefox filename upload. Close #137.
This commit is contained in:
parent
638e2e5c17
commit
18677eec74
@ -49,6 +49,7 @@
|
|||||||
*
|
*
|
||||||
* CONTRIBUTORS
|
* CONTRIBUTORS
|
||||||
*
|
*
|
||||||
|
* desuwa - Firefox filename upload fix
|
||||||
* seaweed - bottom padding for image hover
|
* seaweed - bottom padding for image hover
|
||||||
* e000 - cooldown sanity check
|
* e000 - cooldown sanity check
|
||||||
* ahokadesuka - scroll back when unexpanding images
|
* ahokadesuka - scroll back when unexpanding images
|
||||||
@ -337,7 +338,11 @@
|
|||||||
}
|
}
|
||||||
$.extend(r, callbacks);
|
$.extend(r, callbacks);
|
||||||
$.extend(r.upload, upCallbacks);
|
$.extend(r.upload, upCallbacks);
|
||||||
r.send(form);
|
if (typeof form === 'string') {
|
||||||
|
r.sendAsBinary(form);
|
||||||
|
} else {
|
||||||
|
r.send(form);
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
},
|
},
|
||||||
cache: function(url, cb) {
|
cache: function(url, cb) {
|
||||||
@ -1818,25 +1823,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
post: function(data) {
|
post: function(data) {
|
||||||
var bb, callbacks, form, i, l, name, opts, ui8a, url, val;
|
var boundary, callbacks, form, name, opts, parts, url, val;
|
||||||
form = new FormData();
|
|
||||||
if (engine === 'gecko' && data.upfile) {
|
|
||||||
l = data.upfile.buffer.length;
|
|
||||||
ui8a = new Uint8Array(l);
|
|
||||||
for (i = 0; 0 <= l ? i < l : i > l; 0 <= l ? i++ : i--) {
|
|
||||||
ui8a[i] = data.upfile.buffer.charCodeAt(i);
|
|
||||||
}
|
|
||||||
bb = new MozBlobBuilder();
|
|
||||||
bb.append(ui8a.buffer);
|
|
||||||
form.append('upfile', bb.getBlob(data.upfile.type), data.upfile.name);
|
|
||||||
delete data.upfile;
|
|
||||||
}
|
|
||||||
url = "http://sys.4chan.org/" + data.board + "/post";
|
url = "http://sys.4chan.org/" + data.board + "/post";
|
||||||
delete data.board;
|
delete data.board;
|
||||||
delete data.qr;
|
delete data.qr;
|
||||||
for (name in data) {
|
if (engine === 'gecko' && data.upfile) {
|
||||||
val = data[name];
|
boundary = '-------------SMCD' + Date.now();
|
||||||
if (val) form.append(name, val);
|
parts = [];
|
||||||
|
parts.push('Content-Disposition: form-data; name="upfile"; filename="' + data.upfile.name + '"\r\n' + 'Content-Type: ' + data.upfile.type + '\r\n\r\n' + data.upfile.buffer + '\r\n');
|
||||||
|
delete data.upfile;
|
||||||
|
for (name in data) {
|
||||||
|
val = data[name];
|
||||||
|
if (val) {
|
||||||
|
parts.push('Content-Disposition: form-data; name="' + name + '"\r\n\r\n' + val + '\r\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
form = '--' + boundary + '\r\n' + parts.join('--' + boundary + '\r\n') + '--' + boundary + '--\r\n';
|
||||||
|
} else {
|
||||||
|
form = new FormData();
|
||||||
|
for (name in data) {
|
||||||
|
val = data[name];
|
||||||
|
if (val) form.append(name, val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
callbacks = {
|
callbacks = {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
@ -1864,6 +1872,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (boundary) {
|
||||||
|
opts.headers = {
|
||||||
|
'Content-Type': 'multipart/form-data;boundary=' + boundary
|
||||||
|
};
|
||||||
|
}
|
||||||
return qr.ajax = $.ajax(url, callbacks, opts);
|
return qr.ajax = $.ajax(url, callbacks, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
Cakefile
1
Cakefile
@ -56,6 +56,7 @@ HEADER = """
|
|||||||
*
|
*
|
||||||
* CONTRIBUTORS
|
* CONTRIBUTORS
|
||||||
*
|
*
|
||||||
|
* desuwa - Firefox filename upload fix
|
||||||
* seaweed - bottom padding for image hover
|
* seaweed - bottom padding for image hover
|
||||||
* e000 - cooldown sanity check
|
* e000 - cooldown sanity check
|
||||||
* ahokadesuka - scroll back when unexpanding images
|
* ahokadesuka - scroll back when unexpanding images
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
master
|
master
|
||||||
|
- Mayhem
|
||||||
|
Fix missing image filename uploads. Thanks desuwa.
|
||||||
|
|
||||||
2.25.0
|
2.25.0
|
||||||
- Mayhem
|
- Mayhem
|
||||||
|
|||||||
@ -242,7 +242,7 @@ $.extend $,
|
|||||||
r.setRequestHeader key, val
|
r.setRequestHeader key, val
|
||||||
$.extend r, callbacks
|
$.extend r, callbacks
|
||||||
$.extend r.upload, upCallbacks
|
$.extend r.upload, upCallbacks
|
||||||
r.send form
|
if typeof form is 'string' then r.sendAsBinary form else r.send form
|
||||||
r
|
r
|
||||||
cache: (url, cb) ->
|
cache: (url, cb) ->
|
||||||
if req = $.cache.requests[url]
|
if req = $.cache.requests[url]
|
||||||
@ -1390,28 +1390,27 @@ qr =
|
|||||||
qr.message.post data # Reply object: we're posting
|
qr.message.post data # Reply object: we're posting
|
||||||
|
|
||||||
post: (data) ->
|
post: (data) ->
|
||||||
form = new FormData()
|
|
||||||
|
|
||||||
if engine is 'gecko' and data.upfile
|
|
||||||
# binary string to ArrayBuffer code from Aeosynth's 4chan X
|
|
||||||
l = data.upfile.buffer.length
|
|
||||||
ui8a = new Uint8Array l
|
|
||||||
for i in [0...l]
|
|
||||||
ui8a[i] = data.upfile.buffer.charCodeAt i
|
|
||||||
bb = new MozBlobBuilder()
|
|
||||||
bb.append ui8a.buffer
|
|
||||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=690659
|
|
||||||
# Firefox does not support assigning a filename when appending a blob to a FormData.
|
|
||||||
form.append 'upfile', bb.getBlob(data.upfile.type), data.upfile.name
|
|
||||||
delete data.upfile
|
|
||||||
|
|
||||||
url = "http://sys.4chan.org/#{data.board}/post"
|
url = "http://sys.4chan.org/#{data.board}/post"
|
||||||
# Do not append these values to the form.
|
# Do not append these values to the form.
|
||||||
delete data.board
|
delete data.board
|
||||||
delete data.qr
|
delete data.qr
|
||||||
|
|
||||||
for name, val of data
|
# File with filename upload fix from desuwa
|
||||||
form.append name, val if val
|
if engine is 'gecko' and data.upfile
|
||||||
|
boundary = '-------------SMCD' + Date.now();
|
||||||
|
parts = []
|
||||||
|
parts.push 'Content-Disposition: form-data; name="upfile"; filename="' + data.upfile.name + '"\r\n' + 'Content-Type: ' + data.upfile.type + '\r\n\r\n' + data.upfile.buffer + '\r\n'
|
||||||
|
delete data.upfile
|
||||||
|
|
||||||
|
for name, val of data
|
||||||
|
parts.push 'Content-Disposition: form-data; name="' + name + '"\r\n\r\n' + val + '\r\n' if val
|
||||||
|
form = '--' + boundary + '\r\n' + parts.join('--' + boundary + '\r\n') + '--' + boundary + '--\r\n';
|
||||||
|
|
||||||
|
else
|
||||||
|
form = new FormData()
|
||||||
|
for name, val of data
|
||||||
|
form.append name, val if val
|
||||||
|
|
||||||
callbacks =
|
callbacks =
|
||||||
onload: ->
|
onload: ->
|
||||||
@ -1430,6 +1429,9 @@ qr =
|
|||||||
qr.message.send
|
qr.message.send
|
||||||
req: 'status'
|
req: 'status'
|
||||||
progress: "#{Math.round e.loaded / e.total * 100}%"
|
progress: "#{Math.round e.loaded / e.total * 100}%"
|
||||||
|
if boundary
|
||||||
|
opts.headers =
|
||||||
|
'Content-Type': 'multipart/form-data;boundary=' + boundary
|
||||||
|
|
||||||
qr.ajax = $.ajax url, callbacks, opts
|
qr.ajax = $.ajax url, callbacks, opts
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user