From 92e154fa6496eff2e12ea5055b3c42019778a551 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sun, 30 May 2021 21:49:05 +0100 Subject: [PATCH 1/2] interpret hex sequences in ssid station names resolves #917 --- includes/functions.php | 7 +++++++ includes/wifi_functions.php | 1 + 2 files changed, 8 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index 4f79870a..0e8336b8 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -641,3 +641,10 @@ function validate_host($host) { return preg_match('/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $host); } +function evalHexSequence($string) { + $evaluator = function ($input) { + return hex2bin($input[1]); + }; + return preg_replace_callback('/\\\x(..)/', $evaluator, $string); +} + diff --git a/includes/wifi_functions.php b/includes/wifi_functions.php index 066a19ca..3f4ddd79 100755 --- a/includes/wifi_functions.php +++ b/includes/wifi_functions.php @@ -75,6 +75,7 @@ function nearbyWifiStations(&$networks, $cached = true) } $ssid = trim($arrNetwork[4]); + $ssid = evalHexSequence($ssid); // filter SSID string: anything invisible in 7bit ASCII or quotes -> ignore network if (preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]', $ssid)) { continue; From fe3b8a108eedefbcf0a1fad4e59758b1fc8a0962 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sun, 30 May 2021 21:56:10 +0100 Subject: [PATCH 2/2] properly exclude raspap station from found wifi stations --- includes/wifi_functions.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/wifi_functions.php b/includes/wifi_functions.php index 3f4ddd79..cbd4fc72 100755 --- a/includes/wifi_functions.php +++ b/includes/wifi_functions.php @@ -69,13 +69,15 @@ function nearbyWifiStations(&$networks, $cached = true) foreach (explode("\n", $scan_results) as $network) { $arrNetwork = preg_split("/[\t]+/", $network); // split result into array - if (!array_key_exists(4, $arrNetwork) || - trim($arrNetwork[4]) == $ap_ssid) { - continue; - } $ssid = trim($arrNetwork[4]); $ssid = evalHexSequence($ssid); + + // exclude raspap ssid + if (empty($ssid) || $ssid == $ap_ssid) { + continue; + } + // filter SSID string: anything invisible in 7bit ASCII or quotes -> ignore network if (preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]', $ssid)) { continue;