From 145cfccfcb0f915309bc9bc7299af70c85b53727 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 25 Mar 2017 10:47:12 +0100 Subject: [PATCH] corrections for rngState 82b19a3e7604cf825d --- js/test.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/js/test.js b/js/test.js index b2e4107..f328b51 100644 --- a/js/test.js +++ b/js/test.js @@ -195,9 +195,10 @@ describe('Helper', function () { '(small nearray) string', 'string', function (prefix, params, postfix) { - var prefix = prefix.replace(/%(s|d)/g, '%%'), - postfix = postfix.replace(/%(s|d)/g, '%%'), - result = prefix + params[0] + postfix; + prefix = prefix.replace(/%(s|d)/g, '%%'); + params[0] = params[0].replace(/%(s|d)/g, '%%'); + postfix = postfix.replace(/%(s|d)/g, '%%'); + var result = prefix + params[0] + postfix; params.unshift(prefix + '%s' + postfix); return result === $.PrivateBin.Helper.sprintf.apply(this, params); } @@ -208,9 +209,9 @@ describe('Helper', function () { '(small nearray) nat', 'string', function (prefix, params, postfix) { - var prefix = prefix.replace(/%(s|d)/g, '%%'), - postfix = postfix.replace(/%(s|d)/g, '%%'), - result = prefix + params[0] + postfix; + prefix = prefix.replace(/%(s|d)/g, '%%'); + postfix = postfix.replace(/%(s|d)/g, '%%'); + var result = prefix + params[0] + postfix; params.unshift(prefix + '%d' + postfix); return result === $.PrivateBin.Helper.sprintf.apply(this, params); } @@ -221,9 +222,9 @@ describe('Helper', function () { '(small nearray) falsy', 'string', function (prefix, params, postfix) { - var prefix = prefix.replace(/%(s|d)/g, '%%'), - postfix = postfix.replace(/%(s|d)/g, '%%'), - result = prefix + '0' + postfix; + prefix = prefix.replace(/%(s|d)/g, '%%'); + postfix = postfix.replace(/%(s|d)/g, '%%'); + var result = prefix + '0' + postfix; params.unshift(prefix + '%d' + postfix); return result === $.PrivateBin.Helper.sprintf.apply(this, params) } @@ -236,9 +237,10 @@ describe('Helper', function () { 'string', 'string', function (prefix, uint, middle, string, postfix) { - var prefix = prefix.replace(/%(s|d)/g, '%%'), - postfix = postfix.replace(/%(s|d)/g, '%%'), - params = [prefix + '%d' + middle + '%s' + postfix, uint, string], + prefix = prefix.replace(/%(s|d)/g, '%%'); + middle = middle.replace(/%(s|d)/g, '%%'); + postfix = postfix.replace(/%(s|d)/g, '%%'); + var params = [prefix + '%d' + middle + '%s' + postfix, uint, string], result = prefix + uint + middle + string + postfix; return result === $.PrivateBin.Helper.sprintf.apply(this, params); } @@ -251,9 +253,10 @@ describe('Helper', function () { 'string', 'string', function (prefix, uint, middle, string, postfix) { - var prefix = prefix.replace(/%(s|d)/g, '%%'), - postfix = postfix.replace(/%(s|d)/g, '%%'), - params = [prefix + '%s' + middle + '%d' + postfix, string, uint], + prefix = prefix.replace(/%(s|d)/g, '%%'); + middle = middle.replace(/%(s|d)/g, '%%'); + postfix = postfix.replace(/%(s|d)/g, '%%'); + var params = [prefix + '%s' + middle + '%d' + postfix, string, uint], result = prefix + string + middle + uint + postfix; return result === $.PrivateBin.Helper.sprintf.apply(this, params); } @@ -336,6 +339,7 @@ describe('I18n', function () { 'returns message ID unchanged if no translation found', 'string', function (messageId) { + messageId = messageId.replace(/%(s|d)/g, '%%'); var result = $.PrivateBin.I18n.translate(messageId); $.PrivateBin.I18n.reset(); var alias = $.PrivateBin.I18n._(messageId); @@ -349,9 +353,10 @@ describe('I18n', function () { '(small nearray) string', 'string', function (prefix, params, postfix) { - var prefix = prefix.replace(/%(s|d)/g, '%%'), - postfix = postfix.replace(/%(s|d)/g, '%%'), - translation = prefix + params[0] + postfix; + prefix = prefix.replace(/%(s|d)/g, '%%'); + params[0] = params[0].replace(/%(s|d)/g, '%%'); + postfix = postfix.replace(/%(s|d)/g, '%%'); + var translation = prefix + params[0] + postfix; params.unshift(prefix + '%s' + postfix); var result = $.PrivateBin.I18n.translate.apply(this, params); $.PrivateBin.I18n.reset();