luci-lib-httpclient: accept scoped IPv6 addresses
authorJo-Philipp Wich <jo@mein.io>
Mon, 9 Dec 2019 16:36:05 +0000 (17:36 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 10 Dec 2019 11:32:06 +0000 (12:32 +0100)
Ref: https://github.com/openwrt/luci/issues/3380
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit d87169c0f60f9e7c1f8a61b2809473802093ff31)

libs/luci-lib-httpclient/luasrc/httpclient.lua

index 79ce41294c6074872142d2bcb8cba8bf7f542d5c..e9ec3ac29b9c53b3aeef0bec06a51dbeb06b6ab2 100644 (file)
@@ -105,10 +105,10 @@ function parse_url(uri)
                rest = tmp
        end
 
-       url.host, tmp = rest:match("^%[([0-9a-fA-F:]+)%](.*)$")
+       url.host, tmp = rest:match("^%[(.+)%](.*)$")
        if url.host and tmp then
                url.ip6addr = ip.IPv6(url.host)
-               if not url.ip6addr then
+               if not url.ip6addr or url.ip6addr:prefix() < 128 then
                        return nil
                end
                url.host = string.format("[%s]", url.ip6addr:string())