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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.