Ignore:
Timestamp:
Jan 31, 2018, 2:18:28 AM (7 years ago)
Author:
[email protected]
Message:

JSC incorrectly interpreting script, sets Global Property instead of Global Lexical variable (LiteralParser / JSONP path)
https://bugs.webkit.org/show_bug.cgi?id=182074
<rdar://problem/36846261>

Reviewed by Mark Lam.

JSTests:

  • stress/jsonp-program-evaluate-path-must-consider-global-lexical-environment.js: Added.

(assert):
(let.func):
(let.o.foo):
(varFunc):

LayoutTests/imported/w3c:

  • web-platform-tests/service-workers/service-worker/import-scripts-updated-flag.https-expected.txt:

Source/JavaScriptCore:

This patch teaches the JSONP evaluator about the global lexical environment.
Before, it was using the global object as the global scope, but that's wrong.
The global lexical environment is the first node in the global scope chain.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::executeProgram):

  • jsc.cpp:

(GlobalObject::finishCreation):
(shellSupportsRichSourceInfo):
(functionDisableRichSourceInfo):

  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::tryJSONPParse):

  • runtime/LiteralParser.h:

LayoutTests:

  • http/tests/security/regress-52192-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r226338 r227898  
    342342static EncodedJSValue JSC_HOST_CALL functionHeapCapacity(ExecState*);
    343343static EncodedJSValue JSC_HOST_CALL functionFlashHeapAccess(ExecState*);
     344static EncodedJSValue JSC_HOST_CALL functionDisableRichSourceInfo(ExecState*);
    344345
    345346struct Script {
     
    597598        addFunction(vm, "heapCapacity", functionHeapCapacity, 0);
    598599        addFunction(vm, "flashHeapAccess", functionFlashHeapAccess, 0);
     600
     601        addFunction(vm, "disableRichSourceInfo", functionDisableRichSourceInfo, 0);
    599602    }
    600603   
     
    616619};
    617620
     621static bool supportsRichSourceInfo = true;
     622static bool shellSupportsRichSourceInfo(const JSGlobalObject*)
     623{
     624    return supportsRichSourceInfo;
     625}
     626
    618627const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(GlobalObject) };
    619628const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = {
    620     &supportsRichSourceInfo,
     629    &shellSupportsRichSourceInfo,
    621630    &shouldInterruptScript,
    622631    &javaScriptRuntimeFlags,
     
    17341743}
    17351744
     1745EncodedJSValue JSC_HOST_CALL functionDisableRichSourceInfo(ExecState*)
     1746{
     1747    supportsRichSourceInfo = false;
     1748    return JSValue::encode(jsUndefined());
     1749}
     1750
    17361751template<typename ValueType>
    17371752typename std::enable_if<!std::is_fundamental<ValueType>::value>::type addOption(VM&, JSObject*, Identifier, ValueType) { }
Note: See TracChangeset for help on using the changeset viewer.