Ignore:
Timestamp:
May 8, 2009, 6:01:16 PM (16 years ago)
Author:
[email protected]
Message:

Add a limited literal parser for eval to handle object and array literals fired at eval

Reviewed by Gavin Barraclough and Darin Adler.

This is a simplified parser and lexer that we can throw at strings passed to eval
in case a site is using eval to parse JSON (eg. json2.js). The lexer is intentionally
limited (in effect it's whitelisting a limited "common" subset of the JSON grammar)
as this decreases the likelihood of us wating time attempting to parse any significant
amount of non-JSON content.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r43401 r43424  
    4848#include "JSNotAnObject.h"
    4949#include "JSPropertyNameIterator.h"
     50#include "LiteralParser.h"
    5051#include "JSStaticScopeObject.h"
    5152#include "JSString.h"
     
    337338    UString programSource = asString(program)->value();
    338339
     340    LiteralParser preparser(callFrame, programSource);
     341    if (JSValue parsedObject = preparser.tryLiteralParse())
     342        return parsedObject;
     343   
     344   
    339345    ScopeChainNode* scopeChain = callFrame->scopeChain();
    340346    CodeBlock* codeBlock = callFrame->codeBlock();
Note: See TracChangeset for help on using the changeset viewer.