From 67b9b5f0d8fed0ca886f4f8a8ad3b45bc105d39e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 27 Jun 2019 20:11:22 +0200 Subject: [PATCH] correcting old browser detection logic, fixes #446 --- js/privatebin.js | 10 +++++----- js/test/InitialCheck.js | 5 ++--- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index aa32143..9122e83 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -4580,11 +4580,11 @@ jQuery.PrivateBin = (function($, RawDeflate) { function isOldBrowser() { // webcrypto support if (typeof window.crypto !== 'object') { - return false; + return true; } if (typeof WebAssembly !== 'object' && typeof WebAssembly.instantiate !== 'function') { - return false; + return true; } try { // [\0, 'a', 's', 'm', (uint_32) 1] - smallest valid wasm module @@ -4595,17 +4595,17 @@ jQuery.PrivateBin = (function($, RawDeflate) { new WebAssembly.Instance(module) instanceof WebAssembly.Instance ) ) { - return false; + return true; } } catch (e) { - return false; + return true; } // not checking for async/await, ES6, Promise or Uint8Array support, // as most browsers introduced these earlier then webassembly and webcrypto: // https://github.com/PrivateBin/PrivateBin/pull/431#issuecomment-493129359 - return true; + return false; } /** diff --git a/js/test/InitialCheck.js b/js/test/InitialCheck.js index 7931a9e..5b0778c 100644 --- a/js/test/InitialCheck.js +++ b/js/test/InitialCheck.js @@ -22,6 +22,7 @@ describe('InitialCheck', function () { '' ); $.PrivateBin.Alert.init(); + window.crypto = null; const result1 = !$.PrivateBin.InitialCheck.init(), result2 = !$('#errormessage').hasClass('hidden'); clean(); @@ -48,13 +49,10 @@ describe('InitialCheck', function () { ''+ '' ); - const crypto = window.crypto; - window.crypto = null; $.PrivateBin.Alert.init(); const result1 = !$.PrivateBin.InitialCheck.init(), result2 = isSecureContext === $('#errormessage').hasClass('hidden'), result3 = !$('#oldnotice').hasClass('hidden'); - window.crypto = crypto; clean(); return result1 && result2 && result3; } @@ -78,6 +76,7 @@ describe('InitialCheck', function () { '' ); $.PrivateBin.Alert.init(); + window.crypto = null; const result1 = $.PrivateBin.InitialCheck.init(), result2 = isSecureContext === $('#httpnotice').hasClass('hidden'); clean(); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index e2e7e1d..b60db3a 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -72,7 +72,7 @@ if ($MARKDOWN): endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index 1e0e86c..2733614 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -50,7 +50,7 @@ if ($MARKDOWN): endif; ?> - +