From e8992deab7cecb6e54095bb760613c1cb06b88ca Mon Sep 17 00:00:00 2001 From: Kabir Sala Date: Sat, 1 Mar 2014 21:23:16 +0100 Subject: [PATCH] Better check for dimensions, thanks Zixaphir --- builds/4chan-X.user.js | 20 ++++++-------------- builds/crx/script.js | 20 ++++++-------------- src/Posting/QR.coffee | 17 +++++------------ 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 257f532b1..291519714 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6080,7 +6080,7 @@ return list.value = g.VIEW === 'thread' ? g.THREADID : 'new'; }, dialog: function() { - var dialog, elm, event, i, items, key, max_heigth, max_width, min_heigth, min_width, name, node, nodes, rules, save, tmp_dim, value, _ref; + var dialog, elm, event, i, items, key, name, node, nodes, rules, save, value, _, _ref, _ref1, _ref2; QR.nodes = nodes = { el: dialog = UI.dialog('qr', 'top:0;right:0;', "
×
No selected file
") }; @@ -6115,21 +6115,13 @@ nodes[key] = $(value, dialog); } rules = $('ul.rules').textContent.trim(); + QR.min_width = QR.min_heigth = 1; + QR.max_width = QR.max_heigth = 5000; try { - tmp_dim = rules.match(/.+smaller than (\d+)x(\d+).+/); - min_width = tmp_dim[1]; - min_heigth = tmp_dim[2]; + _ref1 = rules.match(/.+smaller than (\d+)x(\d+).+/), _ = _ref1[0], QR.min_width = _ref1[1], QR.min_heigth = _ref1[2]; + _ref2 = rules.match(/.+greater than (\d+)x(\d+).+/), _ = _ref2[0], QR.max_width = _ref2[1], QR.max_heigth = _ref2[2]; } catch (_error) { - min_width = 1; - min_heigth = 1; - } - try { - tmp_dim = rules.match(/.+greater than (\d+)x(\d+).+/); - max_width = tmp_dim[1]; - max_heigth = tmp_dim[2]; - } catch (_error) { - QR.max_width = 5000; - QR.max_heigth = 5000; + null; } nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = !!$('input[name=spoiler]'); diff --git a/builds/crx/script.js b/builds/crx/script.js index 0688673c2..99691e02e 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6116,7 +6116,7 @@ return list.value = g.VIEW === 'thread' ? g.THREADID : 'new'; }, dialog: function() { - var dialog, elm, event, i, items, key, max_heigth, max_width, min_heigth, min_width, name, node, nodes, rules, save, tmp_dim, value, _ref; + var dialog, elm, event, i, items, key, name, node, nodes, rules, save, value, _, _ref, _ref1, _ref2; QR.nodes = nodes = { el: dialog = UI.dialog('qr', 'top:0;right:0;', "
×
No selected file
") }; @@ -6151,21 +6151,13 @@ nodes[key] = $(value, dialog); } rules = $('ul.rules').textContent.trim(); + QR.min_width = QR.min_heigth = 1; + QR.max_width = QR.max_heigth = 5000; try { - tmp_dim = rules.match(/.+smaller than (\d+)x(\d+).+/); - min_width = tmp_dim[1]; - min_heigth = tmp_dim[2]; + _ref1 = rules.match(/.+smaller than (\d+)x(\d+).+/), _ = _ref1[0], QR.min_width = _ref1[1], QR.min_heigth = _ref1[2]; + _ref2 = rules.match(/.+greater than (\d+)x(\d+).+/), _ = _ref2[0], QR.max_width = _ref2[1], QR.max_heigth = _ref2[2]; } catch (_error) { - min_width = 1; - min_heigth = 1; - } - try { - tmp_dim = rules.match(/.+greater than (\d+)x(\d+).+/); - max_width = tmp_dim[1]; - max_heigth = tmp_dim[2]; - } catch (_error) { - QR.max_width = 5000; - QR.max_heigth = 5000; + null; } nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = !!$('input[name=spoiler]'); diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 37e6d821f..72563de1a 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -450,20 +450,13 @@ QR = } rules = $('ul.rules').textContent.trim() + QR.min_width = QR.min_heigth = 1 + QR.max_width = QR.max_heigth = 5000 try - tmp_dim = rules.match(/.+smaller than (\d+)x(\d+).+/) - min_width = tmp_dim[1] - min_heigth = tmp_dim[2] + [_, QR.min_width, QR.min_heigth] = rules.match(/.+smaller than (\d+)x(\d+).+/) + [_, QR.max_width, QR.max_heigth] = rules.match(/.+greater than (\d+)x(\d+).+/) catch - min_width = 1 - min_heigth = 1 - try - tmp_dim = rules.match(/.+greater than (\d+)x(\d+).+/) - max_width = tmp_dim[1] - max_heigth = tmp_dim[2] - catch - QR.max_width = 5000 - QR.max_heigth = 5000 + null nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value