Merge branch 'master' into js-unit-testing

This commit is contained in:
El RIDO 2018-04-29 08:53:59 +02:00
commit e4bf41202e
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
5 changed files with 37 additions and 3 deletions

View file

@ -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_

View file

@ -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

View file

@ -99,6 +99,30 @@ describe('I18n', function () {
return language === result && language === alias;
}
);
jsc.property(
'should default to en',
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,
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;
}
);
});
});

View file

@ -75,7 +75,7 @@ if ($MARKDOWN):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-uPUi4GuyKJat5CzDmEh0ZhrOVybaJbiyBTLm5vHhjFXxbmoj6wHUuyXHcxg66UDVVHOXRsQClvi74AmA/aqgKA==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mfJhWCkoSbEobT+YpbhF2rN0cyEV27Z3ecHWgCSzl3CMywcRrd4oP/efgOfWXknJJpoqe8341j2hoXD7cSlQEQ==" crossorigin="anonymous"></script>
<!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]-->

View file

@ -54,7 +54,7 @@ if ($QRCODE):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-uPUi4GuyKJat5CzDmEh0ZhrOVybaJbiyBTLm5vHhjFXxbmoj6wHUuyXHcxg66UDVVHOXRsQClvi74AmA/aqgKA==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mfJhWCkoSbEobT+YpbhF2rN0cyEV27Z3ecHWgCSzl3CMywcRrd4oP/efgOfWXknJJpoqe8341j2hoXD7cSlQEQ==" crossorigin="anonymous"></script>
<!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]-->