OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "net/base/escape.h" | 8 #include "net/base/escape.h" |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 {"Hello%20%13%10world %23# %3F? %3D= %26& %25% %2B+", | 175 {"Hello%20%13%10world %23# %3F? %3D= %26& %25% %2B+", |
176 UnescapeRule::URL_SPECIAL_CHARS, | 176 UnescapeRule::URL_SPECIAL_CHARS, |
177 "Hello%20%13%10world ## ?? == && %% ++"}, | 177 "Hello%20%13%10world ## ?? == && %% ++"}, |
178 // We can neither escape nor unescape '@' since some websites expect it to | 178 // We can neither escape nor unescape '@' since some websites expect it to |
179 // be preserved as either '@' or "%40". | 179 // be preserved as either '@' or "%40". |
180 // See http://b/996720 and http://crbug.com/23933 . | 180 // See http://b/996720 and http://crbug.com/23933 . |
181 {"me@my%40example", UnescapeRule::NORMAL, "me@my%40example"}, | 181 {"me@my%40example", UnescapeRule::NORMAL, "me@my%40example"}, |
182 // Control characters. | 182 // Control characters. |
183 {"%01%02%03%04%05%06%07%08%09 %25", UnescapeRule::URL_SPECIAL_CHARS, | 183 {"%01%02%03%04%05%06%07%08%09 %25", UnescapeRule::URL_SPECIAL_CHARS, |
184 "%01%02%03%04%05%06%07%08%09 %"}, | 184 "%01%02%03%04%05%06%07%08%09 %"}, |
185 {"%01%02%03%04%05%06%07%08%09 %25", UnescapeRule::CONTROL_CHARS, | 185 {"%01%02%03%04%05%06%07%08%09 %25", |
| 186 UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
186 "\x01\x02\x03\x04\x05\x06\x07\x08\x09 %25"}, | 187 "\x01\x02\x03\x04\x05\x06\x07\x08\x09 %25"}, |
187 {"Hello%20%13%10%02", UnescapeRule::SPACES, "Hello %13%10%02"}, | 188 {"Hello%20%13%10%02", UnescapeRule::SPACES, "Hello %13%10%02"}, |
188 {"Hello%20%13%10%02", UnescapeRule::CONTROL_CHARS, "Hello%20\x13\x10\x02"}, | 189 {"Hello%20%13%10%02", UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
| 190 "Hello%20\x13\x10\x02"}, |
189 }; | 191 }; |
190 | 192 |
191 for (size_t i = 0; i < arraysize(unescape_cases); i++) { | 193 for (size_t i = 0; i < arraysize(unescape_cases); i++) { |
192 std::string str(unescape_cases[i].input); | 194 std::string str(unescape_cases[i].input); |
193 EXPECT_EQ(std::string(unescape_cases[i].output), | 195 EXPECT_EQ(std::string(unescape_cases[i].output), |
194 UnescapeURLComponent(str, unescape_cases[i].rules)); | 196 UnescapeURLComponent(str, unescape_cases[i].rules)); |
195 } | 197 } |
196 | 198 |
197 // Test the NULL character unescaping (which wouldn't work above since those | 199 // Test the NULL character unescaping (which wouldn't work above since those |
198 // are just char pointers). | 200 // are just char pointers). |
199 std::string input("Null"); | 201 std::string input("Null"); |
200 input.push_back(0); // Also have a NULL in the input. | 202 input.push_back(0); // Also have a NULL in the input. |
201 input.append("%00%39Test"); | 203 input.append("%00%39Test"); |
202 | 204 |
203 // When we're unescaping NULLs | 205 // When we're unescaping NULLs |
204 std::string expected("Null"); | 206 std::string expected("Null"); |
205 expected.push_back(0); | 207 expected.push_back(0); |
206 expected.push_back(0); | 208 expected.push_back(0); |
207 expected.append("9Test"); | 209 expected.append("9Test"); |
208 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::CONTROL_CHARS)); | 210 EXPECT_EQ(expected, UnescapeURLComponent( |
| 211 input, UnescapeRule::SPOOFING_AND_CONTROL_CHARS)); |
209 | 212 |
210 // When we're not unescaping NULLs. | 213 // When we're not unescaping NULLs. |
211 expected = "Null"; | 214 expected = "Null"; |
212 expected.push_back(0); | 215 expected.push_back(0); |
213 expected.append("%009Test"); | 216 expected.append("%009Test"); |
214 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL)); | 217 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL)); |
215 } | 218 } |
216 | 219 |
217 TEST(EscapeTest, UnescapeURLComponent) { | 220 TEST(EscapeTest, UnescapeURLComponent) { |
218 const UnescapeURLCase unescape_cases[] = { | 221 const UnescapeURLCase unescape_cases[] = { |
219 {L"", UnescapeRule::NORMAL, L""}, | 222 {L"", UnescapeRule::NORMAL, L""}, |
220 {L"%2", UnescapeRule::NORMAL, L"%2"}, | 223 {L"%2", UnescapeRule::NORMAL, L"%2"}, |
221 {L"%%%%%%", UnescapeRule::NORMAL, L"%%%%%%"}, | 224 {L"%%%%%%", UnescapeRule::NORMAL, L"%%%%%%"}, |
222 {L"Don't escape anything", UnescapeRule::NORMAL, L"Don't escape anything"}, | 225 {L"Don't escape anything", UnescapeRule::NORMAL, L"Don't escape anything"}, |
223 {L"Invalid %escape %2", UnescapeRule::NORMAL, L"Invalid %escape %2"}, | 226 {L"Invalid %escape %2", UnescapeRule::NORMAL, L"Invalid %escape %2"}, |
224 {L"Some%20random text %25%2dOK", UnescapeRule::NONE, | 227 {L"Some%20random text %25%2dOK", UnescapeRule::NONE, |
225 L"Some%20random text %25%2dOK"}, | 228 L"Some%20random text %25%2dOK"}, |
226 {L"Some%20random text %25%2dOK", UnescapeRule::NORMAL, | 229 {L"Some%20random text %25%2dOK", UnescapeRule::NORMAL, |
227 L"Some%20random text %25-OK"}, | 230 L"Some%20random text %25-OK"}, |
228 {L"Some%20random text %25%E2%80", UnescapeRule::NORMAL, | 231 {L"Some%20random text %25%E2%80", UnescapeRule::NORMAL, |
229 L"Some%20random text %25\xE2\x80"}, | 232 L"Some%20random text %25\xE2\x80"}, |
230 {L"Some%20random text %25%E2%80OK", UnescapeRule::NORMAL, | 233 {L"Some%20random text %25%E2%80OK", UnescapeRule::NORMAL, |
231 L"Some%20random text %25\xE2\x80OK"}, | 234 L"Some%20random text %25\xE2\x80OK"}, |
232 {L"Some%20random text %25%E2%80%84OK", UnescapeRule::NORMAL, | 235 {L"Some%20random text %25%E2%80%84OK", UnescapeRule::NORMAL, |
233 L"Some%20random text %25\xE2\x80\x84OK"}, | 236 L"Some%20random text %25\xE2\x80\x84OK"}, |
234 | 237 |
235 // BiDi Control characters should not be unescaped unless explicity told to | 238 // BiDi Control characters should not be unescaped unless explicity told to |
236 // do so with UnescapeRule::CONTROL_CHARS | 239 // do so with UnescapeRule::SPOOFING_AND_CONTROL_CHARS |
237 {L"Some%20random text %25%D8%9COK", UnescapeRule::NORMAL, | 240 {L"Some%20random text %25%D8%9COK", UnescapeRule::NORMAL, |
238 L"Some%20random text %25%D8%9COK"}, | 241 L"Some%20random text %25%D8%9COK"}, |
239 {L"Some%20random text %25%E2%80%8EOK", UnescapeRule::NORMAL, | 242 {L"Some%20random text %25%E2%80%8EOK", UnescapeRule::NORMAL, |
240 L"Some%20random text %25%E2%80%8EOK"}, | 243 L"Some%20random text %25%E2%80%8EOK"}, |
241 {L"Some%20random text %25%E2%80%8FOK", UnescapeRule::NORMAL, | 244 {L"Some%20random text %25%E2%80%8FOK", UnescapeRule::NORMAL, |
242 L"Some%20random text %25%E2%80%8FOK"}, | 245 L"Some%20random text %25%E2%80%8FOK"}, |
243 {L"Some%20random text %25%E2%80%AAOK", UnescapeRule::NORMAL, | 246 {L"Some%20random text %25%E2%80%AAOK", UnescapeRule::NORMAL, |
244 L"Some%20random text %25%E2%80%AAOK"}, | 247 L"Some%20random text %25%E2%80%AAOK"}, |
245 {L"Some%20random text %25%E2%80%ABOK", UnescapeRule::NORMAL, | 248 {L"Some%20random text %25%E2%80%ABOK", UnescapeRule::NORMAL, |
246 L"Some%20random text %25%E2%80%ABOK"}, | 249 L"Some%20random text %25%E2%80%ABOK"}, |
247 {L"Some%20random text %25%E2%80%AEOK", UnescapeRule::NORMAL, | 250 {L"Some%20random text %25%E2%80%AEOK", UnescapeRule::NORMAL, |
248 L"Some%20random text %25%E2%80%AEOK"}, | 251 L"Some%20random text %25%E2%80%AEOK"}, |
249 {L"Some%20random text %25%E2%81%A6OK", UnescapeRule::NORMAL, | 252 {L"Some%20random text %25%E2%81%A6OK", UnescapeRule::NORMAL, |
250 L"Some%20random text %25%E2%81%A6OK"}, | 253 L"Some%20random text %25%E2%81%A6OK"}, |
251 {L"Some%20random text %25%E2%81%A9OK", UnescapeRule::NORMAL, | 254 {L"Some%20random text %25%E2%81%A9OK", UnescapeRule::NORMAL, |
252 L"Some%20random text %25%E2%81%A9OK"}, | 255 L"Some%20random text %25%E2%81%A9OK"}, |
253 // UnescapeRule::CONTROL_CHARS should unescape BiDi Control characters. | 256 // UnescapeRule::SPOOFING_AND_CONTROL_CHARS should unescape BiDi Control |
| 257 // characters. |
254 {L"Some%20random text %25%D8%9COK", | 258 {L"Some%20random text %25%D8%9COK", |
255 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 259 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
256 L"Some%20random text %25\xD8\x9COK"}, | 260 L"Some%20random text %25\xD8\x9COK"}, |
257 {L"Some%20random text %25%E2%80%8EOK", | 261 {L"Some%20random text %25%E2%80%8EOK", |
258 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 262 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
259 L"Some%20random text %25\xE2\x80\x8EOK"}, | 263 L"Some%20random text %25\xE2\x80\x8EOK"}, |
260 {L"Some%20random text %25%E2%80%8FOK", | 264 {L"Some%20random text %25%E2%80%8FOK", |
261 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 265 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
262 L"Some%20random text %25\xE2\x80\x8FOK"}, | 266 L"Some%20random text %25\xE2\x80\x8FOK"}, |
263 {L"Some%20random text %25%E2%80%AAOK", | 267 {L"Some%20random text %25%E2%80%AAOK", |
264 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 268 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
265 L"Some%20random text %25\xE2\x80\xAAOK"}, | 269 L"Some%20random text %25\xE2\x80\xAAOK"}, |
266 {L"Some%20random text %25%E2%80%ABOK", | 270 {L"Some%20random text %25%E2%80%ABOK", |
267 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 271 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
268 L"Some%20random text %25\xE2\x80\xABOK"}, | 272 L"Some%20random text %25\xE2\x80\xABOK"}, |
269 {L"Some%20random text %25%E2%80%AEOK", | 273 {L"Some%20random text %25%E2%80%AEOK", |
270 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 274 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
271 L"Some%20random text %25\xE2\x80\xAEOK"}, | 275 L"Some%20random text %25\xE2\x80\xAEOK"}, |
272 {L"Some%20random text %25%E2%81%A6OK", | 276 {L"Some%20random text %25%E2%81%A6OK", |
273 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 277 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
274 L"Some%20random text %25\xE2\x81\xA6OK"}, | 278 L"Some%20random text %25\xE2\x81\xA6OK"}, |
275 {L"Some%20random text %25%E2%81%A9OK", | 279 {L"Some%20random text %25%E2%81%A9OK", |
276 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 280 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
277 L"Some%20random text %25\xE2\x81\xA9OK"}, | 281 L"Some%20random text %25\xE2\x81\xA9OK"}, |
278 | 282 |
| 283 // Certain banned characters should not be unescaped unless explicitly told |
| 284 // to do so with UnescapeRule::SPOOFING_AND_CONTROL_CHARS. |
| 285 // U+1F50F LOCK WITH INK PEN |
| 286 {L"Some%20random text %25%F0%9F%94%8FOK", UnescapeRule::NORMAL, |
| 287 L"Some%20random text %25%F0%9F%94%8FOK"}, |
| 288 // U+1F510 CLOSED LOCK WITH KEY |
| 289 {L"Some%20random text %25%F0%9F%94%90OK", UnescapeRule::NORMAL, |
| 290 L"Some%20random text %25%F0%9F%94%90OK"}, |
| 291 // U+1F512 LOCK |
| 292 {L"Some%20random text %25%F0%9F%94%92OK", UnescapeRule::NORMAL, |
| 293 L"Some%20random text %25%F0%9F%94%92OK"}, |
| 294 // U+1F513 OPEN LOCK |
| 295 {L"Some%20random text %25%F0%9F%94%93OK", UnescapeRule::NORMAL, |
| 296 L"Some%20random text %25%F0%9F%94%93OK"}, |
| 297 // UnescapeRule::SPOOFING_AND_CONTROL_CHARS should unescape banned |
| 298 // characters. |
| 299 {L"Some%20random text %25%F0%9F%94%8FOK", |
| 300 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
| 301 L"Some%20random text %25\xF0\x9F\x94\x8FOK"}, |
| 302 {L"Some%20random text %25%F0%9F%94%90OK", |
| 303 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
| 304 L"Some%20random text %25\xF0\x9F\x94\x90OK"}, |
| 305 {L"Some%20random text %25%F0%9F%94%92OK", |
| 306 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
| 307 L"Some%20random text %25\xF0\x9F\x94\x92OK"}, |
| 308 {L"Some%20random text %25%F0%9F%94%93OK", |
| 309 UnescapeRule::NORMAL | UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
| 310 L"Some%20random text %25\xF0\x9F\x94\x93OK"}, |
| 311 |
279 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, | 312 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, |
280 L"Some random text %25-OK"}, | 313 L"Some random text %25-OK"}, |
281 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, | 314 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, |
282 L"Some%20random text %-OK"}, | 315 L"Some%20random text %-OK"}, |
283 {L"Some%20random text %25%2dOK", | 316 {L"Some%20random text %25%2dOK", |
284 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, | 317 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, |
285 L"Some random text %-OK"}, | 318 L"Some random text %-OK"}, |
286 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, | 319 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, |
287 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, | 320 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, |
288 // Certain URL-sensitive characters should not be unescaped unless asked. | 321 // Certain URL-sensitive characters should not be unescaped unless asked. |
289 {L"Hello%20%13%10world %23# %3F? %3D= %26& %25% %2B+", UnescapeRule::SPACES, | 322 {L"Hello%20%13%10world %23# %3F? %3D= %26& %25% %2B+", UnescapeRule::SPACES, |
290 L"Hello %13%10world %23# %3F? %3D= %26& %25% %2B+"}, | 323 L"Hello %13%10world %23# %3F? %3D= %26& %25% %2B+"}, |
291 {L"Hello%20%13%10world %23# %3F? %3D= %26& %25% %2B+", | 324 {L"Hello%20%13%10world %23# %3F? %3D= %26& %25% %2B+", |
292 UnescapeRule::URL_SPECIAL_CHARS, | 325 UnescapeRule::URL_SPECIAL_CHARS, |
293 L"Hello%20%13%10world ## ?? == && %% ++"}, | 326 L"Hello%20%13%10world ## ?? == && %% ++"}, |
294 // We can neither escape nor unescape '@' since some websites expect it to | 327 // We can neither escape nor unescape '@' since some websites expect it to |
295 // be preserved as either '@' or "%40". | 328 // be preserved as either '@' or "%40". |
296 // See http://b/996720 and http://crbug.com/23933 . | 329 // See http://b/996720 and http://crbug.com/23933 . |
297 {L"me@my%40example", UnescapeRule::NORMAL, L"me@my%40example"}, | 330 {L"me@my%40example", UnescapeRule::NORMAL, L"me@my%40example"}, |
298 // Control characters. | 331 // Control characters. |
299 {L"%01%02%03%04%05%06%07%08%09 %25", UnescapeRule::URL_SPECIAL_CHARS, | 332 {L"%01%02%03%04%05%06%07%08%09 %25", UnescapeRule::URL_SPECIAL_CHARS, |
300 L"%01%02%03%04%05%06%07%08%09 %"}, | 333 L"%01%02%03%04%05%06%07%08%09 %"}, |
301 {L"%01%02%03%04%05%06%07%08%09 %25", UnescapeRule::CONTROL_CHARS, | 334 {L"%01%02%03%04%05%06%07%08%09 %25", |
| 335 UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
302 L"\x01\x02\x03\x04\x05\x06\x07\x08\x09 %25"}, | 336 L"\x01\x02\x03\x04\x05\x06\x07\x08\x09 %25"}, |
303 {L"Hello%20%13%10%02", UnescapeRule::SPACES, L"Hello %13%10%02"}, | 337 {L"Hello%20%13%10%02", UnescapeRule::SPACES, L"Hello %13%10%02"}, |
304 {L"Hello%20%13%10%02", UnescapeRule::CONTROL_CHARS, | 338 {L"Hello%20%13%10%02", UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
305 L"Hello%20\x13\x10\x02"}, | 339 L"Hello%20\x13\x10\x02"}, |
306 {L"Hello\x9824\x9827", UnescapeRule::CONTROL_CHARS, | 340 {L"Hello\x9824\x9827", UnescapeRule::SPOOFING_AND_CONTROL_CHARS, |
307 L"Hello\x9824\x9827"}, | 341 L"Hello\x9824\x9827"}, |
308 }; | 342 }; |
309 | 343 |
310 for (size_t i = 0; i < arraysize(unescape_cases); i++) { | 344 for (size_t i = 0; i < arraysize(unescape_cases); i++) { |
311 base::string16 str(base::WideToUTF16(unescape_cases[i].input)); | 345 base::string16 str(base::WideToUTF16(unescape_cases[i].input)); |
312 EXPECT_EQ(base::WideToUTF16(unescape_cases[i].output), | 346 EXPECT_EQ(base::WideToUTF16(unescape_cases[i].output), |
313 UnescapeURLComponent(str, unescape_cases[i].rules)); | 347 UnescapeURLComponent(str, unescape_cases[i].rules)); |
314 } | 348 } |
315 | 349 |
316 // Test the NULL character unescaping (which wouldn't work above since those | 350 // Test the NULL character unescaping (which wouldn't work above since those |
317 // are just char pointers). | 351 // are just char pointers). |
318 base::string16 input(base::WideToUTF16(L"Null")); | 352 base::string16 input(base::WideToUTF16(L"Null")); |
319 input.push_back(0); // Also have a NULL in the input. | 353 input.push_back(0); // Also have a NULL in the input. |
320 input.append(base::WideToUTF16(L"%00%39Test")); | 354 input.append(base::WideToUTF16(L"%00%39Test")); |
321 | 355 |
322 // When we're unescaping NULLs | 356 // When we're unescaping NULLs |
323 base::string16 expected(base::WideToUTF16(L"Null")); | 357 base::string16 expected(base::WideToUTF16(L"Null")); |
324 expected.push_back(0); | 358 expected.push_back(0); |
325 expected.push_back(0); | 359 expected.push_back(0); |
326 expected.append(base::ASCIIToUTF16("9Test")); | 360 expected.append(base::ASCIIToUTF16("9Test")); |
327 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::CONTROL_CHARS)); | 361 EXPECT_EQ(expected, UnescapeURLComponent( |
| 362 input, UnescapeRule::SPOOFING_AND_CONTROL_CHARS)); |
328 | 363 |
329 // When we're not unescaping NULLs. | 364 // When we're not unescaping NULLs. |
330 expected = base::WideToUTF16(L"Null"); | 365 expected = base::WideToUTF16(L"Null"); |
331 expected.push_back(0); | 366 expected.push_back(0); |
332 expected.append(base::WideToUTF16(L"%009Test")); | 367 expected.append(base::WideToUTF16(L"%009Test")); |
333 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL)); | 368 EXPECT_EQ(expected, UnescapeURLComponent(input, UnescapeRule::NORMAL)); |
334 } | 369 } |
335 | 370 |
336 TEST(EscapeTest, UnescapeAndDecodeUTF8URLComponent) { | 371 TEST(EscapeTest, UnescapeAndDecodeUTF8URLComponent) { |
337 const UnescapeAndDecodeCase unescape_cases[] = { | 372 const UnescapeAndDecodeCase unescape_cases[] = { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 "http://example.com/path/sub?q=a|b|c&q=1|2|3#ref|")); | 547 "http://example.com/path/sub?q=a|b|c&q=1|2|3#ref|")); |
513 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C", | 548 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C", |
514 EscapeExternalHandlerValue( | 549 EscapeExternalHandlerValue( |
515 "http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C")); | 550 "http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C")); |
516 ASSERT_EQ("http://[2001:db8:0:1]:80", | 551 ASSERT_EQ("http://[2001:db8:0:1]:80", |
517 EscapeExternalHandlerValue("http://[2001:db8:0:1]:80")); | 552 EscapeExternalHandlerValue("http://[2001:db8:0:1]:80")); |
518 } | 553 } |
519 | 554 |
520 } // namespace | 555 } // namespace |
521 } // namespace net | 556 } // namespace net |
OLD | NEW |