mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-05-02 14:36:08 -04:00
fixing HTTP only error detection in Chrome and Android by ensuring all logic is contained in legacy.js
This commit is contained in:
parent
1a42158dd1
commit
5810f17c31
3 changed files with 38 additions and 4 deletions
38
js/legacy.js
38
js/legacy.js
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue