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

Side by Side Diff: test/mjsunit/regexp.js

Issue 21078: RegExp parser: Fixed unchecked numeric overflow bug. (Closed)
Patch Set: Created 11 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) { 297 if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) {
298 assertTrue(test, testName); 298 assertTrue(test, testName);
299 } else { 299 } else {
300 assertFalse(test, testName); 300 assertFalse(test, testName);
301 } 301 }
302 } 302 }
303 303
304 assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end"); 304 assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end");
305 305
306 // Check decimal escapes doesn't overflow. 306 // Check decimal escapes doesn't overflow.
307 307 // (Note: \214 is interpreted as octal).
308 assertEquals(/\2147483648/.exec("\x8c7483648"), 308 assertEquals(/\2147483648/.exec("\x8c7483648"),
309 ["\x8c7483648"], 309 ["\x8c7483648"],
310 "Overflow decimal escape"); 310 "Overflow decimal escape");
311 311
312
313 // Check numbers in quantifiers doesn't overflow and doesn't throw on
314 // too large numbers.
315 assertFalse(/a{111111111111111111111111111111111111111111111}/.test('b'),
316 "overlarge1");
317 assertFalse(/a{999999999999999999999999999999999999999999999}/.test('b'),
318 "overlarge2");
319 assertFalse(/a{1,111111111111111111111111111111111111111111111}/.test('b'),
320 "overlarge3");
321 assertFalse(/a{1,999999999999999999999999999999999999999999999}/.test('b'),
322 "overlarge4");
323 assertFalse(/a{2147483648}/.test('b'),
324 "overlarge5");
325 assertFalse(/a{21474836471}/.test('b'),
326 "overlarge6");
327 assertFalse(/a{1,2147483648}/.test('b'),
328 "overlarge7");
329 assertFalse(/a{1,21474836471}/.test('b'),
330 "overlarge8");
331 assertFalse(/a{2147483648,2147483648}/.test('b'),
332 "overlarge9");
333 assertFalse(/a{21474836471,21474836471}/.test('b'),
334 "overlarge10");
335 assertFalse(/a{2147483647}/.test('b'),
336 "overlarge11");
337 assertFalse(/a{1,2147483647}/.test('b'),
338 "overlarge12");
339 assertTrue(/a{1,2147483647}/.test('a'),
340 "overlarge13");
341 assertFalse(/a{2147483647,2147483647}/.test('a'),
342 "overlarge14");
343
344
312 // Check that we don't read past the end of the string. 345 // Check that we don't read past the end of the string.
313 assertFalse(/f/.test('b')); 346 assertFalse(/f/.test('b'));
314 assertFalse(/[abc]f/.test('x')); 347 assertFalse(/[abc]f/.test('x'));
315 assertFalse(/[abc]f/.test('xa')); 348 assertFalse(/[abc]f/.test('xa'));
316 assertFalse(/[abc]</.test('x')); 349 assertFalse(/[abc]</.test('x'));
317 assertFalse(/[abc]</.test('xa')); 350 assertFalse(/[abc]</.test('xa'));
318 assertFalse(/f/i.test('b')); 351 assertFalse(/f/i.test('b'));
319 assertFalse(/[abc]f/i.test('x')); 352 assertFalse(/[abc]f/i.test('x'));
320 assertFalse(/[abc]f/i.test('xa')); 353 assertFalse(/[abc]f/i.test('xa'));
321 assertFalse(/[abc]</i.test('x')); 354 assertFalse(/[abc]</i.test('x'));
(...skipping 13 matching lines...) Expand all
335 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt3'); 368 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt3');
336 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt4'); 369 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt4');
337 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt5'); 370 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt5');
338 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt6'); 371 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt6');
339 assertFalse(/xy([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt7'); 372 assertFalse(/xy([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt7');
340 assertFalse(/x([0-7]%%%x|[0-6]%%%y)/.test('x7%%%y'), 'qt8'); 373 assertFalse(/x([0-7]%%%x|[0-6]%%%y)/.test('x7%%%y'), 'qt8');
341 374
342 375
343 // Don't hang on this one. 376 // Don't hang on this one.
344 /[^\xfe-\xff]*/.test(""); 377 /[^\xfe-\xff]*/.test("");
OLDNEW
« src/parser.cc ('K') | « src/parser.cc ('k') | test/mjsunit/regexp-pcre.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698