diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-28 07:23:31 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-28 09:22:59 (GMT) |
commit | a10d523c5010e46b86a74d111342b1b26891cbdf (patch) | |
tree | 06d7ca39e751bc8441f262f0be14b2385795fcba /src/script/api | |
parent | 102493fd341a322a369d21414fdb10aedaf23ff5 (diff) | |
download | Qt-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/script/api')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 6814931..ba1a31f 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1932,7 +1932,14 @@ QScriptValue QScriptEngine::newRegExp(const QString &pattern, const QString &fla JSC::JSValue buf[2]; JSC::ArgList args(buf, sizeof(buf)); JSC::UString jscPattern = QScript::qtStringToJSCUString(pattern); - JSC::UString jscFlags = QScript::qtStringToJSCUString(flags); + QString strippedFlags; + if (flags.contains(QLatin1Char('i'))) + strippedFlags += QLatin1Char('i'); + if (flags.contains(QLatin1Char('m'))) + strippedFlags += QLatin1Char('m'); + if (flags.contains(QLatin1Char('g'))) + strippedFlags += QLatin1Char('g'); + JSC::UString jscFlags = QScript::qtStringToJSCUString(strippedFlags); buf[0] = JSC::jsString(exec, jscPattern); buf[1] = JSC::jsString(exec, jscFlags); JSC::JSObject* result = JSC::constructRegExp(exec, args); |