From 3b0ab7e99facec4c0bfd3fdc9b8676e6afe9b630 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 19 May 2019 08:36:18 +0200 Subject: [PATCH] fixing regression handling v1 key format (un-decoded base64) --- js/privatebin.js | 4 ++-- js/test/Model.js | 14 ++++++-------- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 0c5a8ef..b0267d4 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -1138,11 +1138,11 @@ jQuery.PrivateBin = (function($, RawDeflate) { newKey = newKey.substring(0, ampersandPos); } - // version 2 uses base58, version 1 uses base64 + // version 2 uses base58, version 1 uses base64 without decoding try { symmetricKey = CryptTool.base58decode(newKey); } catch(e) { - symmetricKey = atob(newKey); + symmetricKey = newKey; } } diff --git a/js/test/Model.js b/js/test/Model.js index 6f25f9e..c220716 100644 --- a/js/test/Model.js +++ b/js/test/Model.js @@ -138,16 +138,15 @@ describe('Model', function () { jsc.array(common.jscQueryString()), 'nestring', function (schema, address, query, fragment) { - fragment = fragment.padStart(32, String.fromCharCode(0)); - let fragmentString = common.btoa(fragment), - clean = jsdom('', { + const fragmentString = common.btoa(fragment.padStart(32, String.fromCharCode(0))); + let clean = jsdom('', { url: schema.join('') + '://' + address.join('') + '/?' + query.join('') + '#' + fragmentString }), result = $.PrivateBin.Model.getPasteKey(); $.PrivateBin.Model.reset(); clean(); - return fragment === result; + return fragmentString === result; } ); jsc.property( @@ -158,16 +157,15 @@ describe('Model', function () { 'nestring', jsc.array(common.jscHashString()), function (schema, address, query, fragment, trail) { - fragment = fragment.padStart(32, String.fromCharCode(0)); - let fragmentString = common.btoa(fragment), - clean = jsdom('', { + const fragmentString = common.btoa(fragment.padStart(32, String.fromCharCode(0))); + let clean = jsdom('', { url: schema.join('') + '://' + address.join('') + '/?' + query.join('') + '#' + fragmentString + '&' + trail.join('') }), result = $.PrivateBin.Model.getPasteKey(); $.PrivateBin.Model.reset(); clean(); - return fragment === result; + return fragmentString === result; } ); jsc.property( diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index daaafae..8bc033a 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ if ($MARKDOWN): endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index d6fd35b..4d88b0d 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ if ($MARKDOWN): endif; ?> - +