From c0bcc6daef9429b53c9439c50842483b002bb55d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 22 Sep 2021 14:43:51 +0200 Subject: [PATCH] * Chrome 94.0.4606.54: fix CSP error clicking on sidebox menu Chrome 94 returns all but first single quote "'" in a href attribute as "%27" :( --- pixelegg/js/fw_pixelegg.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pixelegg/js/fw_pixelegg.js b/pixelegg/js/fw_pixelegg.js index 348f89451c..cbab50e694 100644 --- a/pixelegg/js/fw_pixelegg.js +++ b/pixelegg/js/fw_pixelegg.js @@ -138,14 +138,15 @@ var href_regexp = /^javascript:([^\(]+)\((.*)?\);?$/; jQuery('#egw_fw_topmenu_items,#egw_fw_topmenu_info_items,#egw_fw_sidemenu,#egw_fw_footer').on('click','a[href^="javascript:"]',function(ev){ ev.stopPropagation(); // do NOT execute regular event, as it will violate CSP, when handler does NOT return false - var matches = this.href.match(href_regexp); + // fix for Chrome 94.0.4606.54 returning all but first single quote "'" in href as "%27" :( + var matches = this.href.replace(/%27/g, "'").match(href_regexp); var args = []; if (matches.length > 1 && matches[2] !== undefined) { try { args = JSON.parse('['+matches[2]+']'); } - catch(e) { // deal with '-encloded strings (JSON allows only ") + catch(e) { // deal with '-enclosed strings (JSON allows only ") args = JSON.parse('['+matches[2].replace(/','/g, '","').replace(/((^|,)'|'(,|$))/g, '$2"$3')+']'); } }