Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Porter <slug@qwebirc.org>2010-04-24 03:06:36 (GMT)
committer Chris Porter <slug@qwebirc.org>2010-04-24 03:06:36 (GMT)
commit33dde50e7d3bf7dd8ed9c2f5a95d67f1bfa81b72 (patch)
tree47eb8d8180e43f567d7c675927bf357c4a0fdb3a
parentaffb8f3164a9216730347cd95a9ef598689be0f1 (diff)
Add a trivial checksum to prevent strange issues from typing errors in uio URL option.
-rw-r--r--js/jslib.js5
-rw-r--r--js/ui/panes/options.js12
2 files changed, 13 insertions, 4 deletions
diff --git a/js/jslib.js b/js/jslib.js
index b61038d..bbf2c13 100644
--- a/js/jslib.js
+++ b/js/jslib.js
@@ -293,6 +293,11 @@ qwebirc.util.b64Decode = function(data) {
var output = [];
var table = qwebirc.util.b64Table;
+
+ /* grossly inefficient... so sue me */
+ while(data.length % 4 != 0)
+ data = data + "=";
+
for(var i=0;i<data.length;) {
var enc1 = table.indexOf(data.charAt(i++));
var enc2 = table.indexOf(data.charAt(i++));
diff --git a/js/ui/panes/options.js b/js/ui/panes/options.js
index 2422f75..402213a 100644
--- a/js/ui/panes/options.js
+++ b/js/ui/panes/options.js
@@ -430,9 +430,11 @@ qwebirc.ui.SuppliedArgOptions = new Class({
initialize: function(ui, arg) {
var p = {};
- if($defined(arg) && arg != "") {
- var decoded = qwebirc.util.b64Decode(arg);
- if(decoded)
+ if($defined(arg) && arg != "" && arg.length > 2) {
+ var checksum = arg.substr(arg.length - 2, 2);
+ var decoded = qwebirc.util.b64Decode(arg.substr(0, arg.length - 2));
+
+ if(decoded && (new qwebirc.util.crypto.MD5().digest(decoded).slice(0, 2) == checksum))
p = qwebirc.util.parseURI("?" + decoded);
}
@@ -456,7 +458,9 @@ qwebirc.ui.SuppliedArgOptions = new Class({
result.push(x.optionId + "=" + x.value);
}.bind(this));
- return qwebirc.util.b64Encode(result.join("&")).replaceAll("=", "");
+ var raw = result.join("&");
+ var checksum = new qwebirc.util.crypto.MD5().digest(raw).slice(0, 2);
+ return (qwebirc.util.b64Encode(raw)).replaceAll("=", "") + checksum;
}
});