From f9cbdf1cdb0b6aad766cfcf10ce290bc335408f4 Mon Sep 17 00:00:00 2001 From: Alexander Olsson Date: Sun, 25 May 2014 13:07:01 +0200 Subject: [PATCH] Updated dependencies. Base85 changed default spec from ascii85 to z85. Adapt verification in the Canumb API for this. --- package.json | 32 ++++++++++++++++---------------- src/api/decode.js | 11 ++--------- tests/api/decode.js | 8 ++++---- tests/api/encode.js | 4 ++-- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 2d0c7bb..0f6a26c 100644 --- a/package.json +++ b/package.json @@ -13,22 +13,22 @@ "start": "node src/main.js" }, "dependencies": { - "restify": "2.7.x", - "underscore": "1.6.x", - "base85": "0.1.x", - "grunt": "0.4.x", - "grunt-cli": "0.1.x", - "grunt-exec": "0.4.x", - "grunt-curl": "1.4.x", - "grunt-contrib-copy": "0.5.x", - "grunt-contrib-requirejs": "0.4.x", - "bower": "1.3.x", - "node-sass": "0.8.x", - "node-bourbon": "1.0.x", - "nodeunit": "0.8.x", - "newrelic": "1.5.x", - "request": "2.34.x", - "jshint": "2.5.x" + "restify": "^2.8.1", + "underscore": "^1.6.0", + "base85": "^1.2.1", + "grunt": "^0.4.5", + "grunt-cli": "^0.1.13", + "grunt-exec": "^0.4.5", + "grunt-curl": "^1.5.1", + "grunt-contrib-copy": "^0.5.0", + "grunt-contrib-requirejs": "^0.4.4", + "bower": "^1.3.3", + "node-sass": "^0.8.6", + "node-bourbon": "^1.2.3", + "nodeunit": "^0.9.0", + "newrelic": "^1.6.0", + "request": "^2.36.0", + "jshint": "^2.5.1" }, "keywords": [ "number", diff --git a/src/api/decode.js b/src/api/decode.js index 6a4865d..ae8226f 100644 --- a/src/api/decode.js +++ b/src/api/decode.js @@ -32,16 +32,9 @@ function fnbase85(data) /* Ignore leading and trailing white spaces for easier verification */ data = data.trim(); - if (data[0] !== '<' || -  data[1] !== '~' || - data[data.length - 2] !== '~' || -  data[data.length - 1] !== '>') { - throw new errors.InvalidArgument('Base85 data must be enclosed by \'<~\' and \'~>\'.'); - } - var re = - /[^\n !"#$%&'()*+,\-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\]\^_`abcdefghijklmnopqrstu]/; - if (re.test(data.slice(2, -2))) { + /[^0-9a-zA-Z.-:+=^!/*?&<>()[\]{}@%$#]/; + if (re.test(data)) { throw new errors.InvalidArgument('Invalid characters in base85 data.'); } diff --git a/tests/api/decode.js b/tests/api/decode.js index 659ebcb..8998d94 100644 --- a/tests/api/decode.js +++ b/tests/api/decode.js @@ -60,10 +60,10 @@ exports.testInvalidUriDecode = function(test) { exports.testBase85Decode = function(test) { var tests = [ - { 'data' : '<~DIn!&EZf"5DJik~>', 'expected' : 'never gonna' }, - { 'data' : '<~Ch7]2H#IgJA8c[0~>', 'expected' : 'let you down' }, - { 'data' : '<~_kk8H_mT~>', 'expected' : 'åäö' }, - { 'data' : '<~+9~>', 'expected' : ' ' }, + { 'data' : 'zE[05AV/1kzF&>', 'expected' : 'never gonna' }, + { 'data' : 'y?mYhD2E*Fwn=Wf', 'expected' : 'let you down' }, + { 'data' : '.>>nD.)P', 'expected' : 'åäö' }, + { 'data' : 'ao', 'expected' : ' ' }, ]; test.expect(tests.length); diff --git a/tests/api/encode.js b/tests/api/encode.js index 85df360..6c9517d 100644 --- a/tests/api/encode.js +++ b/tests/api/encode.js @@ -47,8 +47,8 @@ exports.testUriEncode = function(test) { exports.testBase85Encode = function(test) { var tests = [ - { 'data' : 'Hello, world!', 'expected' : '<~87cURD_*#TDfTZ)+T~>' }, - { 'data' : 'ay dios mio', 'expected' : '<~@' } + { 'data' : 'Hello, world!', 'expected' : 'nm=QNz.92Pz/PV8aP' }, + { 'data' : 'ay dios mio', 'expected' : 'vr&#ax(w5nze0[' } ]; test.expect(tests.length);