Fwd: kdelibs/kjs

David Faure faure at kde.org
Tue Nov 25 21:16:04 CET 2003


See patch below for a missing check in the RegExp constructor.

Did you by any chance implement any of the 2 TODOs left in that file?
(throwing an exception on invalid flags, and adding the flags in toString?)

----------  Forwarded Message  ----------

Subject: kdelibs/kjs
Date: Tuesday 25 November 2003 21:09
From: David Faure <faure at kde.org>
To: kde-cvs at kde.org
Cc: khtml-cvs at kde.org

CVS commit by faure: 

Add check for (regexp,flags) case and throw TypeError exception in that case, as specified in 15.10.4.1.
Every character of it was reviewed by Harri twice :)


  M +5 -0      ChangeLog   1.34
  M +15 -1     regexp_object.cpp   1.40


--- kdelibs/kjs/ChangeLog  #1.33:1.34
@@ -1,2 +1,7 @@
+2003-11-25  David Faure  <faure at kde.org>
+
+        * regexp_object.cpp (construct): Add check for (regexp,flags) case 
+        and throw TypeError exception in that case, as specified in 15.10.4.1.
+
 2003-11-21  Harri Porten  <porten at kde.org>
 

--- kdelibs/kjs/regexp_object.cpp  #1.39:1.40
@@ -228,6 +228,20 @@ bool RegExpObjectImp::implementsConstruc
 Object RegExpObjectImp::construct(ExecState *exec, const List &args)
 {
-  UString p = args.isEmpty() ? UString("") : args[0].toString(exec);
+  UString p;
   UString flags = args[1].toString(exec);
+  if (args.isEmpty()) {
+      p = "";
+  } else {
+    Value a0 = args[0];
+    if (a0.isA(ObjectType) && a0.toObject(exec).inherits(&RegExpImp::info)) {
+      // It's a regexp. Check that no flags were passed.
+      if (args.size() > 1 && args[1].type() != UndefinedType) {
+          Object err = Error::create(exec,TypeError);
+          exec->setException(err);
+          return err;
+      }
+    }
+    p = a0.toString(exec);
+  }
 
   RegExpPrototypeImp *proto = static_cast<RegExpPrototypeImp*>(exec->interpreter()->builtinRegExpPrototype().imp());





-------------------------------------------------------

-- 
David FAURE, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).


More information about the Khtml-devel mailing list