Changeset 47847 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Aug 27, 2009, 5:27:10 PM (16 years ago)
Author:
[email protected]
Message:

JSON.stringify replacer array does not accept values that are not string primitives.
https://bugs.webkit.org/show_bug.cgi?id=28788

Reviewed by Adam Roben

Update the JSON stringifier to initialise its replacer array according to the most
recent version of the spec.

Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r47845 r47847  
     12009-08-27  Oliver Hunt  <[email protected]>
     2
     3        Reviewed by Adam Roben.
     4
     5        JSON.stringify replacer array does not accept values that are not string primitives.
     6        https://bugs.webkit.org/show_bug.cgi?id=28788
     7
     8        Update the JSON stringifier to initialise its replacer array according to the most
     9        recent version of the spec.
     10
     11        * runtime/Identifier.h:
     12        (JSC::Identifier::from):
     13        * runtime/JSONObject.cpp:
     14        (JSC::Stringifier::Stringifier):
     15
    1162009-08-27  Alexey Proskuryakov  <[email protected]>
    217
     
    5368        * assembler/X86Assembler.h:
    5469        (JSC::CAN_SIGN_EXTEND_8_32):
     70
     712009-08-27  Oliver Hunt  <[email protected]>
     72
     73        Reviewed by Adam Roben.
     74
     75        JSON.stringify replacer array does not accept values that are not string primitives.
     76        https://bugs.webkit.org/show_bug.cgi?id=28788
     77
     78        Update the JSON stringifier to initialise its replacer array according to the most
     79        recent version of the spec.
     80
     81        * runtime/Identifier.h:
     82        (JSC::Identifier::from):
     83        * runtime/JSONObject.cpp:
     84        (JSC::Stringifier::Stringifier):
    5585
    56862009-08-27  Oliver Hunt  <[email protected]>
  • trunk/JavaScriptCore/runtime/Identifier.h

    r44224 r47847  
    5555       
    5656        static Identifier from(ExecState* exec, unsigned y) { return Identifier(exec, UString::from(y)); }
     57        static Identifier from(ExecState* exec, int y) { return Identifier(exec, UString::from(y)); }
     58        static Identifier from(ExecState* exec, double y) { return Identifier(exec, UString::from(y)); }
    5759       
    5860        bool isNull() const { return _ustring.isNull(); }
  • trunk/JavaScriptCore/runtime/JSONObject.cpp

    r47812 r47847  
    203203            if (exec->hadException())
    204204                break;
     205
     206            if (name.isObject()) {
     207                if (!asObject(name)->inherits(&NumberObject::info) && !asObject(name)->inherits(&StringObject::info))
     208                    continue;
     209                name = static_cast<JSWrapperObject*>(asObject(name))->internalValue();
     210            }
     211
    205212            UString propertyName;
    206             if (!name.getString(propertyName))
     213            if (name.getString(propertyName)) {
     214                m_arrayReplacerPropertyNames.add(Identifier(exec, propertyName));
    207215                continue;
     216            }
     217
     218            double value = 0;
     219            if (name.getNumber(value)) {
     220                m_arrayReplacerPropertyNames.add(Identifier::from(exec, value));
     221                continue;
     222            }
     223
    208224            if (exec->hadException())
    209225                return;
    210             m_arrayReplacerPropertyNames.add(Identifier(exec, propertyName));
    211226        }
    212227        return;
Note: See TracChangeset for help on using the changeset viewer.