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

Unified Diff: src/regexp.js

Issue 7624045: Make regexp flag parsing stricter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/regress/regress-219.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index 7b851a35744ac2cc67a52effd91c5f7c72b2bff2..a7f42d59c25ef2e5723df1ac70db16ab05aeb13b 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -50,24 +50,29 @@ function DoConstructRegExp(object, pattern, flags) {
var global = false;
var ignoreCase = false;
var multiline = false;
-
for (var i = 0; i < flags.length; i++) {
var c = %_CallFunction(flags, i, StringCharAt);
switch (c) {
case 'g':
- // Allow duplicate flags to be consistent with JSC and others.
+ if (global) {
+ throw MakeSyntaxError("invalid_regexp_flags", [flags]);
+ }
global = true;
break;
case 'i':
+ if (ignoreCase) {
+ throw MakeSyntaxError("invalid_regexp_flags", [flags]);
+ }
ignoreCase = true;
break;
case 'm':
+ if (multiline) {
+ throw MakeSyntaxError("invalid_regexp_flags", [flags]);
+ }
multiline = true;
break;
default:
- // Ignore flags that have no meaning to be consistent with
- // JSC.
- break;
+ throw MakeSyntaxError("invalid_regexp_flags", [flags]);
}
}
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/regress/regress-219.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698