Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/uri.js

Issue 9415010: Make built-ins strict mode conforming, and support a --use-strict flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Yang's comments. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/string.js ('k') | src/v8natives.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 result[index++] = ch.charCodeAt(0); 243 result[index++] = ch.charCodeAt(0);
244 } 244 }
245 } 245 }
246 result.length = index; 246 result.length = index;
247 return %StringFromCharCodeArray(result); 247 return %StringFromCharCodeArray(result);
248 } 248 }
249 249
250 250
251 // ECMA-262 - 15.1.3.1. 251 // ECMA-262 - 15.1.3.1.
252 function URIDecode(uri) { 252 function URIDecode(uri) {
253 function reservedPredicate(cc) { 253 var reservedPredicate = function(cc) {
254 // #$ 254 // #$
255 if (35 <= cc && cc <= 36) return true; 255 if (35 <= cc && cc <= 36) return true;
256 // & 256 // &
257 if (cc == 38) return true; 257 if (cc == 38) return true;
258 // +, 258 // +,
259 if (43 <= cc && cc <= 44) return true; 259 if (43 <= cc && cc <= 44) return true;
260 // / 260 // /
261 if (cc == 47) return true; 261 if (cc == 47) return true;
262 // :; 262 // :;
263 if (58 <= cc && cc <= 59) return true; 263 if (58 <= cc && cc <= 59) return true;
264 // = 264 // =
265 if (cc == 61) return true; 265 if (cc == 61) return true;
266 // ?@ 266 // ?@
267 if (63 <= cc && cc <= 64) return true; 267 if (63 <= cc && cc <= 64) return true;
268 268
269 return false; 269 return false;
270 } 270 };
271 var string = ToString(uri); 271 var string = ToString(uri);
272 return Decode(string, reservedPredicate); 272 return Decode(string, reservedPredicate);
273 } 273 }
274 274
275 275
276 // ECMA-262 - 15.1.3.2. 276 // ECMA-262 - 15.1.3.2.
277 function URIDecodeComponent(component) { 277 function URIDecodeComponent(component) {
278 function reservedPredicate(cc) { return false; } 278 var reservedPredicate = function(cc) { return false; };
279 var string = ToString(component); 279 var string = ToString(component);
280 return Decode(string, reservedPredicate); 280 return Decode(string, reservedPredicate);
281 } 281 }
282 282
283 283
284 // Does the char code correspond to an alpha-numeric char. 284 // Does the char code correspond to an alpha-numeric char.
285 function isAlphaNumeric(cc) { 285 function isAlphaNumeric(cc) {
286 // a - z 286 // a - z
287 if (97 <= cc && cc <= 122) return true; 287 if (97 <= cc && cc <= 122) return true;
288 // A - Z 288 // A - Z
289 if (65 <= cc && cc <= 90) return true; 289 if (65 <= cc && cc <= 90) return true;
290 // 0 - 9 290 // 0 - 9
291 if (48 <= cc && cc <= 57) return true; 291 if (48 <= cc && cc <= 57) return true;
292 292
293 return false; 293 return false;
294 } 294 }
295 295
296 296
297 // ECMA-262 - 15.1.3.3. 297 // ECMA-262 - 15.1.3.3.
298 function URIEncode(uri) { 298 function URIEncode(uri) {
299 function unescapePredicate(cc) { 299 var unescapePredicate = function(cc) {
300 if (isAlphaNumeric(cc)) return true; 300 if (isAlphaNumeric(cc)) return true;
301 // ! 301 // !
302 if (cc == 33) return true; 302 if (cc == 33) return true;
303 // #$ 303 // #$
304 if (35 <= cc && cc <= 36) return true; 304 if (35 <= cc && cc <= 36) return true;
305 // &'()*+,-./ 305 // &'()*+,-./
306 if (38 <= cc && cc <= 47) return true; 306 if (38 <= cc && cc <= 47) return true;
307 // :; 307 // :;
308 if (58 <= cc && cc <= 59) return true; 308 if (58 <= cc && cc <= 59) return true;
309 // = 309 // =
310 if (cc == 61) return true; 310 if (cc == 61) return true;
311 // ?@ 311 // ?@
312 if (63 <= cc && cc <= 64) return true; 312 if (63 <= cc && cc <= 64) return true;
313 // _ 313 // _
314 if (cc == 95) return true; 314 if (cc == 95) return true;
315 // ~ 315 // ~
316 if (cc == 126) return true; 316 if (cc == 126) return true;
317 317
318 return false; 318 return false;
319 } 319 };
320 320
321 var string = ToString(uri); 321 var string = ToString(uri);
322 return Encode(string, unescapePredicate); 322 return Encode(string, unescapePredicate);
323 } 323 }
324 324
325 325
326 // ECMA-262 - 15.1.3.4 326 // ECMA-262 - 15.1.3.4
327 function URIEncodeComponent(component) { 327 function URIEncodeComponent(component) {
328 function unescapePredicate(cc) { 328 var unescapePredicate = function(cc) {
329 if (isAlphaNumeric(cc)) return true; 329 if (isAlphaNumeric(cc)) return true;
330 // ! 330 // !
331 if (cc == 33) return true; 331 if (cc == 33) return true;
332 // '()* 332 // '()*
333 if (39 <= cc && cc <= 42) return true; 333 if (39 <= cc && cc <= 42) return true;
334 // -. 334 // -.
335 if (45 <= cc && cc <= 46) return true; 335 if (45 <= cc && cc <= 46) return true;
336 // _ 336 // _
337 if (cc == 95) return true; 337 if (cc == 95) return true;
338 // ~ 338 // ~
339 if (cc == 126) return true; 339 if (cc == 126) return true;
340 340
341 return false; 341 return false;
342 } 342 };
343 343
344 var string = ToString(component); 344 var string = ToString(component);
345 return Encode(string, unescapePredicate); 345 return Encode(string, unescapePredicate);
346 } 346 }
347 347
348 348
349 function HexValueOf(code) { 349 function HexValueOf(code) {
350 // 0-9 350 // 0-9
351 if (code >= 48 && code <= 57) return code - 48; 351 if (code >= 48 && code <= 57) return code - 48;
352 // A-F 352 // A-F
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 "escape", URIEscape, 415 "escape", URIEscape,
416 "unescape", URIUnescape, 416 "unescape", URIUnescape,
417 "decodeURI", URIDecode, 417 "decodeURI", URIDecode,
418 "decodeURIComponent", URIDecodeComponent, 418 "decodeURIComponent", URIDecodeComponent,
419 "encodeURI", URIEncode, 419 "encodeURI", URIEncode,
420 "encodeURIComponent", URIEncodeComponent 420 "encodeURIComponent", URIEncodeComponent
421 )); 421 ));
422 } 422 }
423 423
424 SetUpUri(); 424 SetUpUri();
OLDNEW
« no previous file with comments | « src/string.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698