From c6950b9b56d32c51f4808d439d035f5b9dc2af38 Mon Sep 17 00:00:00 2001 From: Alexander Do Date: Sat, 7 Apr 2018 02:53:00 +0000 Subject: [PATCH 1/5] Default to en if browser does not provide a language --- js/privatebin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/privatebin.js b/js/privatebin.js index a39c38a..436a7de 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -441,7 +441,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { // auto-select language based on browser settings if (newLanguage.length === 0) { - newLanguage = (navigator.language || navigator.userLanguage).substring(0, 2); + newLanguage = (navigator.language || navigator.userLanguage || 'en').substring(0, 2); } // if language is already used skip update From 944c8c291254b657ba75de1c046f3817bb8f03ea Mon Sep 17 00:00:00 2001 From: Alexander Do Date: Sat, 7 Apr 2018 03:22:26 +0000 Subject: [PATCH 2/5] Add test for missing browser language --- js/test/I18n.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/test/I18n.js b/js/test/I18n.js index 0d2fc08..c3a69b2 100644 --- a/js/test/I18n.js +++ b/js/test/I18n.js @@ -99,6 +99,28 @@ describe('I18n', function () { return language === result && language === alias; } ); + + jsc.property( + 'should default to en', + function() { + var clean = jsdom('', {url: 'https://privatebin.net/'}); + + [ 'language', 'userLanguage' ].forEach(function (key) { + Object.defineProperty(navigator, key, { + value: undefined, + writeable: false + }); + }); + + $.PrivateBin.I18n.reset('en'); + $.PrivateBin.I18n.loadTranslations(); + var result = $.PrivateBin.I18n.translate('en'), + alias = $.PrivateBin.I18n._('en'); + + clean(); + return 'en' === result && 'en' === alias; + } + ); }); }); From 09a04b96c0a7e9d1f0f9d0a2a66084e06a398462 Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 8 Apr 2018 23:09:13 +0200 Subject: [PATCH 3/5] Update SRI hashes --- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index a886875..890d159 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -75,7 +75,7 @@ if ($MARKDOWN): - + diff --git a/tpl/page.php b/tpl/page.php index d1e2d90..ee95728 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -54,7 +54,7 @@ if ($QRCODE): - + From cb6a6200b9eeaa7cbec12fd2cdb8d290c7aa3776 Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 8 Apr 2018 23:33:30 +0200 Subject: [PATCH 4/5] Add missing license for kjua --- LICENSE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/LICENSE.md b/LICENSE.md index 05a4125..8492fc3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -30,6 +30,16 @@ the following restrictions: 3. This notice may not be removed or altered from any source distribution. +### MIT license for kjua + +Copyright (c) 2016 Lars Jung (https://larsjung.de) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ## GNU General Public License, version 2.0, for SJCL, rawdeflate and rawinflate _Version 2, June 1991_ From 3b9002055933e570e55add041c90c2db5d620c55 Mon Sep 17 00:00:00 2001 From: rugk Date: Mon, 9 Apr 2018 14:13:18 +0200 Subject: [PATCH 5/5] Add explanation Ref https://github.com/PrivateBin/PrivateBin/pull/297#issuecomment-379586428 --- js/test/I18n.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/test/I18n.js b/js/test/I18n.js index c3a69b2..10d333a 100644 --- a/js/test/I18n.js +++ b/js/test/I18n.js @@ -105,6 +105,8 @@ describe('I18n', function () { function() { var clean = jsdom('', {url: 'https://privatebin.net/'}); + // when navigator.userLanguage is undefined and no default language + // is specified, it would throw an error [ 'language', 'userLanguage' ].forEach(function (key) { Object.defineProperty(navigator, key, { value: undefined,