[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:50:45 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 49e24b9a60e0fe1a5b35ffcfe91d47e2bcc9348c
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 8 15:21:12 2003 +0000

            Reviewed by John Sullivan.
    
            - fixed 3365527 -- subscripting JavaScript strings does not work (leads to hang at www.newmagna.com.au)
    
            The JavaScript specification says nothing about this, but other browsers seem to give
            read-only access to the characters in a string as if the string was an array of characters.
    
            * kjs/array_object.cpp:
            (ArrayInstanceImp::get): Update to use a public toArrayIndex function instead of our own getArrayIndex
            function, so we can share with string.
            (ArrayInstanceImp::put): Ditto.
            (ArrayInstanceImp::hasProperty): Ditto.
            (ArrayInstanceImp::setLength): Ditto.
    
            * kjs/ustring.h: Add toArrayIndex.
            * kjs/ustring.cpp: (UString::toArrayIndex): Added. Implements the rule from array.
            * kjs/identifier.h: Add a forwarding function so we can use toArrayIndex.
    
            * kjs/string_object.cpp:
            (StringInstanceImp::get): Return a single character string if the property name is an array index.
            (StringInstanceImp::hasProperty): Return true for property names that are suitable array indices.
    
            * JavaScriptCore.pbproj/project.pbxproj: Let Xcode be Xcode.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4792 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 9c179af..e1acf5e 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,29 @@
+2003-08-07  Darin Adler  <darin at apple.com>
+
+        Reviewed by John Sullivan.
+
+        - fixed 3365527 -- subscripting JavaScript strings does not work (leads to hang at www.newmagna.com.au)
+
+        The JavaScript specification says nothing about this, but other browsers seem to give
+        read-only access to the characters in a string as if the string was an array of characters.
+
+        * kjs/array_object.cpp:
+        (ArrayInstanceImp::get): Update to use a public toArrayIndex function instead of our own getArrayIndex
+        function, so we can share with string.
+        (ArrayInstanceImp::put): Ditto.
+        (ArrayInstanceImp::hasProperty): Ditto.
+        (ArrayInstanceImp::setLength): Ditto.
+
+        * kjs/ustring.h: Add toArrayIndex.
+        * kjs/ustring.cpp: (UString::toArrayIndex): Added. Implements the rule from array.
+        * kjs/identifier.h: Add a forwarding function so we can use toArrayIndex.
+
+        * kjs/string_object.cpp:
+        (StringInstanceImp::get): Return a single character string if the property name is an array index.
+        (StringInstanceImp::hasProperty): Return true for property names that are suitable array indices.
+
+        * JavaScriptCore.pbproj/project.pbxproj: Let Xcode be Xcode.
+
 === Safari-92 ===
 
 2003-08-07  Maciej Stachowiak  <mjs at apple.com>
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 9c179af..e1acf5e 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,29 @@
+2003-08-07  Darin Adler  <darin at apple.com>
+
+        Reviewed by John Sullivan.
+
+        - fixed 3365527 -- subscripting JavaScript strings does not work (leads to hang at www.newmagna.com.au)
+
+        The JavaScript specification says nothing about this, but other browsers seem to give
+        read-only access to the characters in a string as if the string was an array of characters.
+
+        * kjs/array_object.cpp:
+        (ArrayInstanceImp::get): Update to use a public toArrayIndex function instead of our own getArrayIndex
+        function, so we can share with string.
+        (ArrayInstanceImp::put): Ditto.
+        (ArrayInstanceImp::hasProperty): Ditto.
+        (ArrayInstanceImp::setLength): Ditto.
+
+        * kjs/ustring.h: Add toArrayIndex.
+        * kjs/ustring.cpp: (UString::toArrayIndex): Added. Implements the rule from array.
+        * kjs/identifier.h: Add a forwarding function so we can use toArrayIndex.
+
+        * kjs/string_object.cpp:
+        (StringInstanceImp::get): Return a single character string if the property name is an array index.
+        (StringInstanceImp::hasProperty): Return true for property names that are suitable array indices.
+
+        * JavaScriptCore.pbproj/project.pbxproj: Let Xcode be Xcode.
+
 === Safari-92 ===
 
 2003-08-07  Maciej Stachowiak  <mjs at apple.com>
diff --git a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
index 24f73bf..9c5e9e4 100644
--- a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
@@ -75,6 +75,8 @@
 //083
 //084
 		0867D690FE84028FC02AAC07 = {
+			buildSettings = {
+			};
 			buildStyles = (
 				014CEA440018CDF011CA2923,
 				014CEA450018CDF011CA2923,
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 8afe630..f25790a 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -70,25 +70,14 @@ ArrayInstanceImp::~ArrayInstanceImp()
   free(storage);
 }
 
-// Rule from ECMA 15.2 about what an array index is.
-// Must exactly match string form of an unsigned integer, and be less than 2^32 - 1.
-bool getArrayIndex(const Identifier &propertyName, unsigned &index)
-{
-  bool ok;
-  unsigned i = propertyName.toStrictUInt32(&ok);
-  if (!ok || i >= 0xFFFFFFFFU)
-    return false;
-  index = i;
-  return true;
-}
-
 Value ArrayInstanceImp::get(ExecState *exec, const Identifier &propertyName) const
 {
   if (propertyName == lengthPropertyName)
     return Number(length);
 
-  unsigned index;
-  if (getArrayIndex(propertyName, index)) {
+  bool ok;
+  unsigned index = propertyName.toArrayIndex(&ok);
+  if (ok) {
     if (index >= length)
       return Undefined();
     if (index < storageLength) {
@@ -120,8 +109,9 @@ void ArrayInstanceImp::put(ExecState *exec, const Identifier &propertyName, cons
     return;
   }
   
-  unsigned index;
-  if (getArrayIndex(propertyName, index)) {
+  bool ok;
+  unsigned index = propertyName.toArrayIndex(&ok);
+  if (ok) {
     put(exec, index, value, attr);
     return;
   }
@@ -153,8 +143,9 @@ bool ArrayInstanceImp::hasProperty(ExecState *exec, const Identifier &propertyNa
   if (propertyName == lengthPropertyName)
     return true;
   
-  unsigned index;
-  if (getArrayIndex(propertyName, index)) {
+  bool ok;
+  unsigned index = propertyName.toArrayIndex(&ok);
+  if (ok) {
     if (index >= length)
       return false;
     if (index < storageLength) {
@@ -261,8 +252,9 @@ void ArrayInstanceImp::setLength(unsigned newLength, ExecState *exec)
     ReferenceListIterator it = sparseProperties.begin();
     while (it != sparseProperties.end()) {
       Reference ref = it++;
-      unsigned index;
-      if (getArrayIndex(ref.getPropertyName(exec), index) && index > newLength) {
+      bool ok;
+      unsigned index = ref.getPropertyName(exec).toArrayIndex(&ok);
+      if (ok && index > newLength) {
 	ref.deleteValue(exec);
       }
     }
diff --git a/JavaScriptCore/kjs/identifier.h b/JavaScriptCore/kjs/identifier.h
index 3301607..44f5c79 100644
--- a/JavaScriptCore/kjs/identifier.h
+++ b/JavaScriptCore/kjs/identifier.h
@@ -53,6 +53,7 @@ namespace KJS {
         unsigned long toULong(bool *ok) const { return _ustring.toULong(ok); }
         uint32_t toUInt32(bool *ok) const { return _ustring.toUInt32(ok); }
         uint32_t toStrictUInt32(bool *ok) const { return _ustring.toStrictUInt32(ok); }
+        unsigned toArrayIndex(bool *ok) const { return _ustring.toArrayIndex(ok); }
         double toDouble() const { return _ustring.toDouble(); }
         
         static const Identifier &null();
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index e1bd909..60bc29f 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -54,6 +54,18 @@ Value StringInstanceImp::get(ExecState *exec, const Identifier &propertyName) co
 {
   if (propertyName == lengthPropertyName)
     return Number(internalValue().toString(exec).size());
+
+  bool ok;
+  const unsigned index = propertyName.toArrayIndex(&ok);
+  if (ok) {
+    const UString s = internalValue().toString(exec);
+    const unsigned length = s.size();
+    if (index >= length)
+      return Undefined();
+    const UChar c = s[index];
+    return String(UString(&c, 1));
+  }
+
   return ObjectImp::get(exec, propertyName);
 }
 
@@ -68,6 +80,15 @@ bool StringInstanceImp::hasProperty(ExecState *exec, const Identifier &propertyN
 {
   if (propertyName == lengthPropertyName)
     return true;
+
+  bool ok;
+  const unsigned index = propertyName.toArrayIndex(&ok);
+  if (ok) {
+    const unsigned length = internalValue().toString(exec).size();
+    if (index < length)
+      return true;
+  }
+
   return ObjectImp::hasProperty(exec, propertyName);
 }
 
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index 30d975a..b6fae6c 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -708,6 +708,16 @@ uint32_t UString::toStrictUInt32(bool *ok) const
   }
 }
 
+// Rule from ECMA 15.2 about what an array index is.
+// Must exactly match string form of an unsigned integer, and be less than 2^32 - 1.
+unsigned UString::toArrayIndex(bool *ok) const
+{
+  unsigned i = toStrictUInt32(ok);
+  if (i >= 0xFFFFFFFFU && ok)
+    *ok = false;
+  return i;
+}
+
 int UString::find(const UString &f, int pos) const
 {
   int sz = size();
diff --git a/JavaScriptCore/kjs/ustring.h b/JavaScriptCore/kjs/ustring.h
index 6d97cb1..9d59cf1 100644
--- a/JavaScriptCore/kjs/ustring.h
+++ b/JavaScriptCore/kjs/ustring.h
@@ -387,6 +387,14 @@ namespace KJS {
     uint32_t toStrictUInt32(bool *ok = 0) const;
 
     /**
+     * Attempts an conversion to an array index. The "ok" boolean will be set
+     * to true if it is a valid array index according to the rule from
+     * ECMA 15.2 about what an array index is. It must exactly match the string
+     * form of an unsigned integer, and be less than 2^32 - 1.
+     */
+    unsigned toArrayIndex(bool *ok = 0) const;
+
+    /**
      * @return Position of first occurrence of f starting at position pos.
      * -1 if the search was not successful.
      */

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list