diff options
author | Herbert Leuwer <herbert.leuwer@t-online.de> | 2017-11-22 09:30:12 +0100 |
---|---|---|
committer | Herbert Leuwer <herbert.leuwer@t-online.de> | 2017-11-22 09:30:12 +0100 |
commit | 2d6a0f7bda9241f827a3edbfa738603c024a423b (patch) | |
tree | eb03ce5ce9b0089d9728b7ea57ef35d3be374978 /test | |
parent | 3ee89515a0ef4852f64b13133c22aa7d3a322cfd (diff) | |
download | luasocket-2d6a0f7bda9241f827a3edbfa738603c024a423b.tar.gz luasocket-2d6a0f7bda9241f827a3edbfa738603c024a423b.tar.bz2 luasocket-2d6a0f7bda9241f827a3edbfa738603c024a423b.zip |
fixed url parsing; postpone fragment parsing after authority parsing; added test cases to test/urltest.lua
fixed reference patterns in check_protect() to upper case hex letters
Diffstat (limited to 'test')
-rw-r--r-- | test/urltest.lua | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/test/urltest.lua b/test/urltest.lua index 32cb348..1090a7e 100644 --- a/test/urltest.lua +++ b/test/urltest.lua | |||
@@ -91,6 +91,75 @@ end | |||
91 | 91 | ||
92 | print("testing URL parsing") | 92 | print("testing URL parsing") |
93 | check_parse_url{ | 93 | check_parse_url{ |
94 | url = "scheme://user:pass$%?#wd@host:port/path;params?query#fragment", | ||
95 | scheme = "scheme", | ||
96 | authority = "user:pass$%?#wd@host:port", | ||
97 | host = "host", | ||
98 | port = "port", | ||
99 | userinfo = "user:pass$%?#wd", | ||
100 | password = "pass$%?#wd", | ||
101 | user = "user", | ||
102 | path = "/path", | ||
103 | params = "params", | ||
104 | query = "query", | ||
105 | fragment = "fragment" | ||
106 | } | ||
107 | check_parse_url{ | ||
108 | url = "scheme://user:pass?#wd@host:port/path;params?query#fragment", | ||
109 | scheme = "scheme", | ||
110 | authority = "user:pass?#wd@host:port", | ||
111 | host = "host", | ||
112 | port = "port", | ||
113 | userinfo = "user:pass?#wd", | ||
114 | password = "pass?#wd", | ||
115 | user = "user", | ||
116 | path = "/path", | ||
117 | params = "params", | ||
118 | query = "query", | ||
119 | fragment = "fragment" | ||
120 | } | ||
121 | check_parse_url{ | ||
122 | url = "scheme://user:pass-wd@host:port/path;params?query#fragment", | ||
123 | scheme = "scheme", | ||
124 | authority = "user:pass-wd@host:port", | ||
125 | host = "host", | ||
126 | port = "port", | ||
127 | userinfo = "user:pass-wd", | ||
128 | password = "pass-wd", | ||
129 | user = "user", | ||
130 | path = "/path", | ||
131 | params = "params", | ||
132 | query = "query", | ||
133 | fragment = "fragment" | ||
134 | } | ||
135 | check_parse_url{ | ||
136 | url = "scheme://user:pass#wd@host:port/path;params?query#fragment", | ||
137 | scheme = "scheme", | ||
138 | authority = "user:pass#wd@host:port", | ||
139 | host = "host", | ||
140 | port = "port", | ||
141 | userinfo = "user:pass#wd", | ||
142 | password = "pass#wd", | ||
143 | user = "user", | ||
144 | path = "/path", | ||
145 | params = "params", | ||
146 | query = "query", | ||
147 | fragment = "fragment" | ||
148 | } | ||
149 | check_parse_url{ | ||
150 | url = "scheme://user:pass#wd@host:port/path;params?query", | ||
151 | scheme = "scheme", | ||
152 | authority = "user:pass#wd@host:port", | ||
153 | host = "host", | ||
154 | port = "port", | ||
155 | userinfo = "user:pass#wd", | ||
156 | password = "pass#wd", | ||
157 | user = "user", | ||
158 | path = "/path", | ||
159 | params = "params", | ||
160 | query = "query", | ||
161 | } | ||
162 | check_parse_url{ | ||
94 | url = "scheme://userinfo@host:port/path;params?query#fragment", | 163 | url = "scheme://userinfo@host:port/path;params?query#fragment", |
95 | scheme = "scheme", | 164 | scheme = "scheme", |
96 | authority = "userinfo@host:port", | 165 | authority = "userinfo@host:port", |
@@ -608,9 +677,9 @@ check_parse_path("eu/tu", { "eu", "tu" }) | |||
608 | print("testing path protection") | 677 | print("testing path protection") |
609 | check_protect({ "eu", "-_.!~*'():@&=+$,", "tu" }, "eu/-_.!~*'():@&=+$,/tu") | 678 | check_protect({ "eu", "-_.!~*'():@&=+$,", "tu" }, "eu/-_.!~*'():@&=+$,/tu") |
610 | check_protect({ "eu ", "~diego" }, "eu%20/~diego") | 679 | check_protect({ "eu ", "~diego" }, "eu%20/~diego") |
611 | check_protect({ "/eu>", "<diego?" }, "%2feu%3e/%3cdiego%3f") | 680 | check_protect({ "/eu>", "<diego?" }, "%2Feu%3E/%3Cdiego%3F") |
612 | check_protect({ "\\eu]", "[diego`" }, "%5ceu%5d/%5bdiego%60") | 681 | check_protect({ "\\eu]", "[diego`" }, "%5Ceu%5D/%5Bdiego%60") |
613 | check_protect({ "{eu}", "|diego\127" }, "%7beu%7d/%7cdiego%7f") | 682 | check_protect({ "{eu}", "|diego\127" }, "%7Beu%7D/%7Cdiego%7F") |
614 | check_protect({ "eu ", "~diego" }, "eu /~diego", 1) | 683 | check_protect({ "eu ", "~diego" }, "eu /~diego", 1) |
615 | check_protect({ "/eu>", "<diego?" }, "/eu>/<diego?", 1) | 684 | check_protect({ "/eu>", "<diego?" }, "/eu>/<diego?", 1) |
616 | check_protect({ "\\eu]", "[diego`" }, "\\eu]/[diego`", 1) | 685 | check_protect({ "\\eu]", "[diego`" }, "\\eu]/[diego`", 1) |