summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-07-28 07:23:31 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-28 09:22:59 (GMT)
commita10d523c5010e46b86a74d111342b1b26891cbdf (patch)
tree06d7ca39e751bc8441f262f0be14b2385795fcba /src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp
parent102493fd341a322a369d21414fdb10aedaf23ff5 (diff)
downloadQt-a10d523c5010e46b86a74d111342b1b26891cbdf.zip
Qt-a10d523c5010e46b86a74d111342b1b26891cbdf.tar.gz
Qt-a10d523c5010e46b86a74d111342b1b26891cbdf.tar.bz2
Change JavaScriptCore so it throw error when passing invalid regexp flag
As specified in the specification. The QScriptEngine::newRegExp on the other hand used to work with invalid flags. Reviewed-by: Kent Hansen
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp
index 7dd4a8f..95a5714 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExp.cpp
@@ -72,12 +72,33 @@ inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const US
{
// NOTE: The global flag is handled on a case-by-case basis by functions like
// String::match and RegExpObject::match.
+#ifndef QT_BUILD_SCRIPT_LIB
if (flags.find('g') != -1)
m_flagBits |= Global;
if (flags.find('i') != -1)
m_flagBits |= IgnoreCase;
if (flags.find('m') != -1)
m_flagBits |= Multiline;
+#else //Invalid flags should throw a SyntaxError (ECMA Script 15.10.4.1)
+ static const char flagError[] = "invalid regular expression flag";
+ for (int i = 0; i < flags.size(); i++) {
+ switch (flags.data()[i]) {
+ case 'g':
+ m_flagBits |= Global;
+ break;
+ case 'i':
+ m_flagBits |= IgnoreCase;
+ break;
+ case 'm':
+ m_flagBits |= Multiline;
+ break;
+ default:
+ m_constructionError = flagError;
+ m_regExp = 0;
+ return;
+ }
+ }
+#endif
compile(globalData);
}