From 70c38db81de136de609992b2f770000974e6f8da Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 18 Sep 2019 07:47:26 +0200 Subject: [PATCH] adding ES6 and async feature detection to correctly flag old chromes and operas with the modern browser error --- js/legacy.js | 13 ++++++++++--- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/js/legacy.js b/js/legacy.js index e50a64d..64f565a 100644 --- a/js/legacy.js +++ b/js/legacy.js @@ -174,9 +174,16 @@ return true; } - // not checking for async/await, ES6 or Promise support, as most - // browsers introduced these earlier then webassembly and webcrypto: - // https://github.com/PrivateBin/PrivateBin/pull/431#issuecomment-493129359 + // async & ES6 support + try { + eval('async () => {}'); + } catch (e) { + if (e instanceof SyntaxError) { + return true; + } else { + throw e; // throws CSP error + } + } return false; } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index c8ffa8b..d484edf 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -71,7 +71,7 @@ if ($MARKDOWN): endif; ?> - +