From ab66db334661477be29d11ac70045e9b2968c82e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Oct 2020 16:02:11 +0200 Subject: [locationinfo] URLPANEL: Allow black- and whitelist simultaneously References #3790 --- .../locationinfo/inc/locationinfohooks.inc.php | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'modules-available/locationinfo/inc/locationinfohooks.inc.php') diff --git a/modules-available/locationinfo/inc/locationinfohooks.inc.php b/modules-available/locationinfo/inc/locationinfohooks.inc.php index b0596c10..8e4975e9 100644 --- a/modules-available/locationinfo/inc/locationinfohooks.inc.php +++ b/modules-available/locationinfo/inc/locationinfohooks.inc.php @@ -36,8 +36,16 @@ class LocationInfoHooks ConfigHolder::add('SLX_BROWSER_RELOAD_SECS', $data['reload-minutes'] * 60); } ConfigHolder::add('SLX_BROWSER_URL', $data['url']); - ConfigHolder::add('SLX_BROWSER_URLLIST', $data['urllist']); - ConfigHolder::add('SLX_BROWSER_IS_WHITELIST', $data['iswhitelist']); + // Mangle non-upgraded panels + if (empty($data['blacklist']) && $data['whitelist'] === '*' && !empty($data['urllist'])) { + if ($data['iswhitelist']) { + $data['whitelist'] = str_replace(' ', "\n", $data['urllist']); + } else { + $data['blacklist'] = str_replace(' ', "\n", $data['urllist']); + } + } + ConfigHolder::add('SLX_BROWSER_WHITELIST', self::mangleList($data['whitelist'])); + ConfigHolder::add('SLX_BROWSER_BLACKLIST', self::mangleList($data['blacklist'])); // Additionally, update runmode "isclient" flag depending on whether split-login is allowed or not if (isset($data['split-login']) && $data['split-login']) { RunMode::updateClientFlag($machineUuid, 'locationinfo', true); @@ -76,4 +84,15 @@ class LocationInfoHooks ConfigHolder::add('SLX_SYSTEM_STANDBY_TIMEOUT', '', 1000); } + /** + * Turn multiline list into space separated list, removing any + * comments (starting with #) + * @param string $list + * @return string + */ + private static function mangleList($list) + { + return preg_replace('/\s*(#[^\n]*)?(\n|$)/', ' ', $list); + } + } \ No newline at end of file -- cgit v1.2.3-55-g7522