summaryrefslogtreecommitdiffhomepage
path: root/libs/httpclient/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-02-05 13:44:07 +0000
committerJo-Philipp Wich <jow@openwrt.org>2014-02-05 13:44:07 +0000
commitb92a01d3ae1d1bbb74f23469c929f60df69339be (patch)
tree820d9fd33a04207d8e21886b50c3b45360b9a2eb /libs/httpclient/luasrc
parentc1bd1e59d3fcdd31ddec9a2795ace53c41993e8b (diff)
httpclient: fix parsing of IPv6 URLs (#662)
Diffstat (limited to 'libs/httpclient/luasrc')
-rw-r--r--libs/httpclient/luasrc/httpclient.lua19
1 files changed, 15 insertions, 4 deletions
diff --git a/libs/httpclient/luasrc/httpclient.lua b/libs/httpclient/luasrc/httpclient.lua
index 93eed05c63..c866be6855 100644
--- a/libs/httpclient/luasrc/httpclient.lua
+++ b/libs/httpclient/luasrc/httpclient.lua
@@ -108,11 +108,22 @@ end
function request_raw(uri, options)
options = options or {}
local pr, auth, host, port, path
- if uri:find("@") then
- pr, auth, host, port, path =
- uri:match("(%w+)://(.+)@([%w-.]+):?([0-9]*)(.*)")
+
+ if uri:find("%[") then
+ if uri:find("@") then
+ pr, auth, host, port, path = uri:match("(%w+)://(.+)@(%b[]):?([0-9]*)(.*)")
+ host = host:sub(2,-2)
+ else
+ pr, host, port, path = uri:match("(%w+)://(%b[]):?([0-9]*)(.*)")
+ host = host:sub(2,-2)
+ end
else
- pr, host, port, path = uri:match("(%w+)://([%w-.]+):?([0-9]*)(.*)")
+ if uri:find("@") then
+ pr, auth, host, port, path =
+ uri:match("(%w+)://(.+)@([%w-.]+):?([0-9]*)(.*)")
+ else
+ pr, host, port, path = uri:match("(%w+)://([%w-.]+):?([0-9]*)(.*)")
+ end
end
if not host then