Changeset 43424 in webkit for trunk/JavaScriptCore/runtime


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.

Location:
trunk/JavaScriptCore/runtime
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r43372 r43424  
    2929#include "GlobalEvalFunction.h"
    3030#include "JSGlobalObject.h"
     31#include "LiteralParser.h"
    3132#include "JSString.h"
    3233#include "Interpreter.h"
     
    282283    UString s = x.toString(exec);
    283284
     285    LiteralParser preparser(exec, s);
     286    if (JSValue parsedObject = preparser.tryLiteralParse())
     287        return parsedObject;
     288
    284289    int errLine;
    285290    UString errMsg;
Note: See TracChangeset for help on using the changeset viewer.