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 <tim.wilkinson@me.com>

* Update ports

added %s* infront of the port range input in case a whitespace has been inserted.

Co-authored-by: Tim Wilkinson <tim.wilkinson@me.com>
This commit is contained in:
VA2XJM Jean-Michel 2022-12-22 11:31:41 -05:00 committed by GitHub
parent 29d1251831
commit 74810d01b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -11,3 +11,4 @@ Steve Lewis - AB7PA <ab7pa.radio@gmail.com>
Tim Wilkinson - KN6PLV <tim.j.wilkinson@gmail.com>
Phil Crump - M0DNY <phil@philcrump.co.uk>
Paul Milazzo - K3PGM <milazzo@comcast.net>
Jean-Michel Vien - VA2XJM <va2xjm@gmail.com>

View File

@ -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

View File

@ -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