fixing HTTP only error detection in Chrome and Android by ensuring all logic is contained in legacy.js

This commit is contained in:
El RIDO 2019-09-17 21:41:25 +02:00
parent 1a42158dd1
commit 5810f17c31
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
3 changed files with 38 additions and 4 deletions

View file

@ -188,6 +188,35 @@ jQuery.Legacy = (function($) {
return false;
}
/**
* shows an error message
*
* @private
* @name Check.showError
* @param {string} message
* @function
*/
function showError(message)
{
var $error = $('#errormessage'),
$glyphIcon = $error.find(':first'),
$element;
if ($glyphIcon.length) {
// if there is an icon, we need to provide an inner element
// to translate the message into, instead of the parent
$element = $('<span>');
$error.html(' ').prepend($glyphIcon).append($element);
} else {
$element = $error;
}
if (message.indexOf('<a') === -1) {
$element.text(message);
} else {
$element.html(message);
}
$error.removeClass('hidden');
}
/**
* returns if the check has concluded
*
@ -223,7 +252,7 @@ jQuery.Legacy = (function($) {
// prevent bots from viewing a paste and potentially deleting data
// when burn-after-reading is set
if (isBadBot()) {
$.PrivateBin.Alert.showError('I love you too, bot…');
showError('I love you too, bot…');
init = true;
return;
}
@ -231,7 +260,12 @@ jQuery.Legacy = (function($) {
if (isOldBrowser()) {
// some browsers (Chrome based ones) would have webcrypto support if using HTTPS
if (!isSecureContext()) {
$.PrivateBin.Alert.showError(['Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href="%s">switching to HTTPS</a>.', 'https' + window.location.href.slice(4)]);
showError(
'Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href="%s">switching to HTTPS</a>.'.replace(
'%s',
'https' + window.location.href.slice(4)
)
);
}
$('#oldnotice').removeClass('hidden');
init = true;