I puked a little in Firefags' mouths.
This commit is contained in:
parent
dc7994c9ba
commit
b1aecb607a
@ -1823,19 +1823,37 @@
|
||||
}
|
||||
},
|
||||
post: function(data) {
|
||||
var boundary, callbacks, form, name, opts, parts, url, val;
|
||||
var boundary, callbacks, form, name, opts, parts, toUTF8, url, val;
|
||||
url = "http://sys.4chan.org/" + data.board + "/post";
|
||||
delete data.board;
|
||||
delete data.qr;
|
||||
if (engine === 'gecko' && data.upfile) {
|
||||
toUTF8 = function(val) {
|
||||
var c, n, utf, _ref;
|
||||
utf = '';
|
||||
for (n = 0, _ref = val.length - 1; 0 <= _ref ? n <= _ref : n >= _ref; 0 <= _ref ? n++ : n--) {
|
||||
c = val.charCodeAt(n);
|
||||
if (c < 128) {
|
||||
utf += String.fromCharCode(c);
|
||||
} else if ((127 < c && c < 2048)) {
|
||||
utf += String.fromCharCode((c >> 6) | 192);
|
||||
utf += String.fromCharCode((c & 63) | 128);
|
||||
} else {
|
||||
utf += String.fromCharCode((c >> 12) | 224);
|
||||
utf += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utf += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
}
|
||||
return utf;
|
||||
};
|
||||
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');
|
||||
parts.push('Content-Disposition: form-data; name="upfile"; filename="' + toUTF8(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');
|
||||
parts.push('Content-Disposition: form-data; name="' + name + '"\r\n\r\n' + toUTF8(val) + '\r\n');
|
||||
}
|
||||
}
|
||||
form = '--' + boundary + '\r\n' + parts.join('--' + boundary + '\r\n') + '--' + boundary + '--\r\n';
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
master
|
||||
- Mayhem
|
||||
Fix image posting on Firefox along with Unicode characters in the form.
|
||||
|
||||
2.25.1
|
||||
- Mayhem
|
||||
|
||||
@ -1398,13 +1398,28 @@ qr =
|
||||
|
||||
# File with filename upload fix from desuwa
|
||||
if engine is 'gecko' and data.upfile
|
||||
toUTF8 = (val) ->
|
||||
utf = ''
|
||||
for n in [0..val.length-1]
|
||||
c = val.charCodeAt n
|
||||
if c < 128
|
||||
utf += String.fromCharCode c
|
||||
else if 127 < c < 2048
|
||||
utf += String.fromCharCode (c >> 6) | 192
|
||||
utf += String.fromCharCode (c & 63) | 128
|
||||
else
|
||||
utf += String.fromCharCode (c >> 12) | 224
|
||||
utf += String.fromCharCode ((c >> 6) & 63) | 128
|
||||
utf += String.fromCharCode (c & 63) | 128
|
||||
utf
|
||||
|
||||
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'
|
||||
parts.push 'Content-Disposition: form-data; name="upfile"; filename="' + toUTF8(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
|
||||
parts.push 'Content-Disposition: form-data; name="' + name + '"\r\n\r\n' + toUTF8(val) + '\r\n' if val
|
||||
form = '--' + boundary + '\r\n' + parts.join('--' + boundary + '\r\n') + '--' + boundary + '--\r\n'
|
||||
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user