summaryrefslogtreecommitdiffhomepage
path: root/libs/luci-lib-httpclient/luasrc/httpclient.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-12-11 09:17:42 +0100
committerJo-Philipp Wich <jo@mein.io>2018-12-11 09:17:50 +0100
commita692ca789ae916b1393a39236ff8cf3e8a431717 (patch)
treef387b024d9c57d127a20b4412902a291309d7a22 /libs/luci-lib-httpclient/luasrc/httpclient.lua
parenta54baf7be0d293b50c6b2754c11d61e6e2ad82af (diff)
luci-lib-httpclient: prevent nil access with invalid IP address literals
Fixes: a54baf7be ("luci-lib-httpclient: revamp URL handling") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'libs/luci-lib-httpclient/luasrc/httpclient.lua')
-rw-r--r--libs/luci-lib-httpclient/luasrc/httpclient.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/luci-lib-httpclient/luasrc/httpclient.lua b/libs/luci-lib-httpclient/luasrc/httpclient.lua
index f19fa44387..79ce41294c 100644
--- a/libs/luci-lib-httpclient/luasrc/httpclient.lua
+++ b/libs/luci-lib-httpclient/luasrc/httpclient.lua
@@ -108,20 +108,20 @@ function parse_url(uri)
url.host, tmp = rest:match("^%[([0-9a-fA-F:]+)%](.*)$")
if url.host and tmp then
url.ip6addr = ip.IPv6(url.host)
- url.host = string.format("[%s]", url.ip6addr:string())
- rest = tmp
if not url.ip6addr then
return nil
end
+ url.host = string.format("[%s]", url.ip6addr:string())
+ rest = tmp
else
url.host, tmp = rest:match("^(%d+%.%d+%.%d+%.%d+)(.*)$")
if url.host and tmp then
url.ipaddr = ip.IPv4(url.host)
- url.host = url.ipaddr:string()
- rest = tmp
if not url.ipaddr then
return nil
end
+ url.host = url.ipaddr:string()
+ rest = tmp
else
url.host, tmp = rest:match("^([0-9a-zA-Z%.%-]+)(.*)$")
if url.host and tmp then