Created
December 9, 2019 07:50
-
-
Save jow-/b93d2454a42e224096982eb86221806c to your computer and use it in GitHub Desktop.
Allow scoped IPv6 addresses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/libs/luci-lib-httpclient/luasrc/httpclient.lua b/libs/luci-lib-httpclient/luasrc/httpclient.lua | |
| index 79ce41294..7a335a016 100644 | |
| --- a/libs/luci-lib-httpclient/luasrc/httpclient.lua | |
| +++ b/libs/luci-lib-httpclient/luasrc/httpclient.lua | |
| @@ -105,13 +105,18 @@ 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) | |
| + local ip, scope = url.host:match("^([^%%]+)%%(.+)$") | |
| + url.ip6addr = ip.IPv6(ip or url.host) | |
| if not url.ip6addr then | |
| return nil | |
| end | |
| - url.host = string.format("[%s]", url.ip6addr:string()) | |
| + if scope then | |
| + url.host = string.format("[%s%%%s]", url.ip6addr:string(), scope) | |
| + else | |
| + url.host = string.format("[%s]", url.ip6addr:string()) | |
| + end | |
| rest = tmp | |
| else | |
| url.host, tmp = rest:match("^(%d+%.%d+%.%d+%.%d+)(.*)$") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment