From 642b1cd37d994be5ed8c2f17fa5951b309bea4d1 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 23 Mar 2014 17:19:19 -0700 Subject: [PATCH 1/2] Small Linkifier miss involving hostname.com:port --- builds/4chan-X.user.js | 2 +- builds/crx/script.js | 2 +- src/Linkification/Linkify.coffee | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 9bdd85bea..0bbac0591 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -8523,7 +8523,7 @@ } } }, - regString: /((https?|mailto|git|magnet|ftp|irc):([a-z\d%\/])|[-a-z\d]+[.](aero|asia|biz|cat|com|coop|info|int|jobs|mobi|museum|name|net|org|post|pro|tel|travel|xxx|edu|gov|mil|[a-z]{2})(\/|(?!.))|[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}|[-\w\d.@]+@[a-z\d.-]+\.[a-z\d])/i, + regString: /((https?|mailto|git|magnet|ftp|irc):([a-z\d%\/])|[-a-z\d]+[.](aero|asia|biz|cat|com|coop|info|int|jobs|mobi|museum|name|net|org|post|pro|tel|travel|xxx|edu|gov|mil|[a-z]{2})([:\/]|(?!.))|[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}|[-\w\d.@]+@[a-z\d.-]+\.[a-z\d])/i, makeRange: function(startNode, endNode, startOffset, endOffset) { var range; range = document.createRange(); diff --git a/builds/crx/script.js b/builds/crx/script.js index 1e4c864fc..146e670e3 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -8538,7 +8538,7 @@ } } }, - regString: /((https?|mailto|git|magnet|ftp|irc):([a-z\d%\/])|[-a-z\d]+[.](aero|asia|biz|cat|com|coop|info|int|jobs|mobi|museum|name|net|org|post|pro|tel|travel|xxx|edu|gov|mil|[a-z]{2})(\/|(?!.))|[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}|[-\w\d.@]+@[a-z\d.-]+\.[a-z\d])/i, + regString: /((https?|mailto|git|magnet|ftp|irc):([a-z\d%\/])|[-a-z\d]+[.](aero|asia|biz|cat|com|coop|info|int|jobs|mobi|museum|name|net|org|post|pro|tel|travel|xxx|edu|gov|mil|[a-z]{2})([:\/]|(?!.))|[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}|[-\w\d.@]+@[a-z\d.-]+\.[a-z\d])/i, makeRange: function(startNode, endNode, startOffset, endOffset) { var range; range = document.createRange(); diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 1748cbd7f..3b92d062f 100755 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -76,7 +76,7 @@ Linkify = | # This should account for virtually all links posted without http: [-a-z\d]+[.]( aero|asia|biz|cat|com|coop|info|int|jobs|mobi|museum|name|net|org|post|pro|tel|travel|xxx|edu|gov|mil|[a-z]{2} - )(/|(?!.)) + )([:/]|(?!.)) | # IPv4 Addresses [\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3} | # E-mails From e20a82248186f4360f2cc8534b53cf184c6104a3 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 23 Mar 2014 17:46:21 -0700 Subject: [PATCH 2/2] Since we already are generating keys, lets use them. --- builds/crx/script.js | 14 ++++++++------ src/General/lib/$.coffee | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/builds/crx/script.js b/builds/crx/script.js index 146e670e3..ecd3c2dac 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -797,20 +797,22 @@ }; timeout = {}; setArea = function(area) { - var data; + var data, keys; data = items[area]; - if (!Object.keys(data).length || timeout[area] > Date.now()) { + keys = Object.keys(data); + if (!keys.length || timeout[area] > Date.now()) { return; } chrome.storage[area].set(data, function() { - var key, val; + var key, val, _i, _len; if (chrome.runtime.lastError) { c.error(chrome.runtime.lastError.message); - for (key in data) { - val = data[key]; - if (!(!(key in items[area]))) { + for (_i = 0, _len = keys.length; _i < _len; _i++) { + key = keys[_i]; + if (!(!items[area][key])) { continue; } + val = data[key]; if (area === 'sync' && chrome.storage.sync.QUOTA_BYTES_PER_ITEM < JSON.stringify(val).length + key.length) { c.error(chrome.runtime.lastError.message, key, val); continue; diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index 7762d8a17..a957fa75d 100755 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -347,11 +347,13 @@ do -> timeout = {} setArea = (area) -> data = items[area] - return if !Object.keys(data).length or timeout[area] > Date.now() + keys = Object.keys data + return if !keys.length or timeout[area] > Date.now() chrome.storage[area].set data, -> if chrome.runtime.lastError c.error chrome.runtime.lastError.message - for key, val of data when key not of items[area] + for key in keys when !items[area][key] + val = data[key] if area is 'sync' and chrome.storage.sync.QUOTA_BYTES_PER_ITEM < JSON.stringify(val).length + key.length c.error chrome.runtime.lastError.message, key, val continue