From 74810d01b4a54bfc2809c97bda5ca048f9eb12fe Mon Sep 17 00:00:00 2001 From: VA2XJM Jean-Michel Date: Thu, 22 Dec 2022 11:31:41 -0500 Subject: [PATCH] Fix port range not working (#569) * Fix for port ranges Fix port range validation. * Update CONTRIBUTORS added myself * Update files/usr/lib/lua/aredn/utils.lua Reverting to whitespace protection plus escaping hyppen. Co-authored-by: Tim Wilkinson * Update ports added %s* infront of the port range input in case a whitespace has been inserted. Co-authored-by: Tim Wilkinson --- CONTRIBUTORS | 1 + files/usr/lib/lua/aredn/utils.lua | 4 ++-- files/www/cgi-bin/ports | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 281434ba..c6a65dfc 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -11,3 +11,4 @@ Steve Lewis - AB7PA Tim Wilkinson - KN6PLV Phil Crump - M0DNY Paul Milazzo - K3PGM +Jean-Michel Vien - VA2XJM \ No newline at end of file diff --git a/files/usr/lib/lua/aredn/utils.lua b/files/usr/lib/lua/aredn/utils.lua index cd73eba6..ff9f181b 100755 --- a/files/usr/lib/lua/aredn/utils.lua +++ b/files/usr/lib/lua/aredn/utils.lua @@ -511,14 +511,14 @@ function validate_port_range(range) if not range then return false end - local port1, port2 = range:match("^%s*(%d+)%s*-%s*(%d+)%s*$") + local port1, port2 = range:match("^%s*(%d+)%s*%-%s*(%d+)%s*$") if not port2 then return false end if not validate_port(port1) or not validate_port(port2) then return false end - if tonumber(port2) > tonumber(port1) then + if tonumber(port1) > tonumber(port2) then return false end return true diff --git a/files/www/cgi-bin/ports b/files/www/cgi-bin/ports index f88a0eca..77e90e0c 100755 --- a/files/www/cgi-bin/ports +++ b/files/www/cgi-bin/ports @@ -368,7 +368,7 @@ if f then if _out:match("-") then if validate_port_range(_out) then - _in = _out:match("^(%d+)") + _in = _out:match("^%s*(%d+)") else porterr(val .. "'" .. _out .. "' is not a valid port range") end