travelmate: fix captive portal detection
authorDirk Brenken <dev@brenken.org>
Wed, 29 Apr 2020 12:48:36 +0000 (14:48 +0200)
committerDirk Brenken <dev@brenken.org>
Wed, 29 Apr 2020 12:48:36 +0000 (14:48 +0200)
* made captive portal detection more bullet proof, fixes #11990

Signed-off-by: Dirk Brenken <dev@brenken.org>
net/travelmate/Makefile
net/travelmate/files/travelmate.sh

index 2c3be78392f7424e84461b394c6fadb98463e2d7..997ba12e3e0bcb1747a7016fb38a1a14babf495b 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=travelmate
 PKG_VERSION:=1.5.4
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 4a5f583bd623415a676aedf332e6794a3cb1c097..660b1635b082585da48c2543f8dbaf4a5c1e314f 100755 (executable)
@@ -226,10 +226,15 @@ f_prepif()
 #
 f_net()
 {
-       local IFS result
+       local IFS raw result
 
-       result="$(${trm_fetch} --timeout=$((trm_maxwait/6)) "${trm_captiveurl}" -O /dev/null 2>&1 | tail -n 1)"
-       result="$(printf "%s" "${result//[\?\$\%\&\+\|\'\"\:]*/}" | awk '/^Failed to redirect|^Redirected/{printf "%s" "net cp \047"$NF"\047";exit}/^Download completed/{printf "%s" "net ok";exit}/^Failed|Connection error/{printf "%s" "net nok";exit}')"
+       raw="$(${trm_fetch} --timeout=$((trm_maxwait/6)) "${trm_captiveurl}" -O /dev/null 2>&1 | tail -n 1)"
+       raw="$(printf "%s" "${raw//[\?\$\%\&\+\|\'\"\:\*\=\/]/ }")"
+       result="$(printf "%s" "${raw}" | awk '/^Failed to redirect|^Redirected/{printf "%s","net cp";exit}/^Download completed/{printf "%s","net ok";exit}/^Failed|Connection error/{printf "%s","net nok";exit}')"
+       if [ "${result}" = "net cp" ]
+       then
+               result="$(printf "%s" "${raw//*on /}" | awk 'match($0,/^([[:alnum:]_-]+\.)+[[:alpha:]]+/){printf "%s","net cp \047"substr(tolower($0),RSTART,RLENGTH)"\047"}')"
+       fi
        printf "%s" "${result}"
        f_log "debug" "f_net     ::: fetch: ${trm_fetch}, timeout: $((trm_maxwait/6)), url: ${trm_captiveurl}, result: ${result}"
 }