Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (91870 => 91871)
--- trunk/Source/_javascript_Core/ChangeLog 2011-07-27 21:50:57 UTC (rev 91870)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-07-27 21:55:40 UTC (rev 91871)
@@ -1,3 +1,20 @@
+2011-07-27 Oliver Hunt <[email protected]>
+
+ Handle callback oriented JSONP
+ https://bugs.webkit.org/show_bug.cgi?id=65271
+
+ Reviewed by Gavin Barraclough.
+
+ Handle the callback oriented versions of JSONP. The Literal parser
+ now handles <Identifier> (. <Identifier>)* (jsonData).
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::execute):
+ * runtime/LiteralParser.cpp:
+ (JSC::LiteralParser::tryJSONPParse):
+ (JSC::LiteralParser::Lexer::lex):
+ * runtime/LiteralParser.h:
+
2011-07-27 Stephanie Lewis <[email protected]>
Revert http://trac.webkit.org/changeset/90415.
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (91870 => 91871)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2011-07-27 21:50:57 UTC (rev 91870)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2011-07-27 21:55:40 UTC (rev 91871)
@@ -776,7 +776,7 @@
DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get());
LiteralParser literalParser(callFrame, program->source().data(), program->source().length(), LiteralParser::JSONP);
Vector<LiteralParser::JSONPData> JSONPData;
- if (literalParser.tryJSONPParse(JSONPData)) {
+ if (literalParser.tryJSONPParse(JSONPData, scopeChain->globalObject->supportsRichSourceInfo())) {
JSGlobalObject* globalObject = scopeChain->globalObject.get();
JSValue result;
for (unsigned entry = 0; entry < JSONPData.size(); entry++) {
@@ -825,6 +825,22 @@
}
PutPropertySlot slot;
switch (JSONPPath.last().m_type) {
+ case LiteralParser::JSONPPathEntryTypeCall: {
+ JSValue function = baseObject.get(callFrame, JSONPPath.last().m_pathEntryName);
+ if (callFrame->hadException())
+ return jsUndefined();
+ CallData callData;
+ CallType callType = getCallData(function, callData);
+ if (callType == CallTypeNone)
+ return throwError(callFrame, createNotAFunctionError(callFrame, function));
+ MarkedArgumentBuffer jsonArg;
+ jsonArg.append(JSONPValue);
+ JSValue thisValue = JSONPPath.size() == 1 ? jsUndefined(): baseObject;
+ JSC::call(callFrame, function, callType, callData, thisValue, jsonArg);
+ if (callFrame->hadException())
+ return jsUndefined();
+ break;
+ }
case LiteralParser::JSONPPathEntryTypeDot: {
baseObject.put(callFrame, JSONPPath.last().m_pathEntryName, JSONPValue, slot);
if (callFrame->hadException())
Modified: trunk/Source/_javascript_Core/runtime/LiteralParser.cpp (91870 => 91871)
--- trunk/Source/_javascript_Core/runtime/LiteralParser.cpp 2011-07-27 21:50:57 UTC (rev 91870)
+++ trunk/Source/_javascript_Core/runtime/LiteralParser.cpp 2011-07-27 21:55:40 UTC (rev 91871)
@@ -42,7 +42,7 @@
return c == ' ' || c == 0x9 || c == 0xA || c == 0xD;
}
-bool LiteralParser::tryJSONPParse(Vector<JSONPData>& results)
+bool LiteralParser::tryJSONPParse(Vector<JSONPData>& results, bool needsFullSourceInfo)
{
if (m_lexer.next() != TokIdentifier)
return false;
@@ -87,18 +87,31 @@
entry.m_pathEntryName = Identifier(m_exec, m_lexer.currentToken().start, m_lexer.currentToken().end - m_lexer.currentToken().start);
break;
}
+ case TokLParen: {
+ if (path.last().m_type != JSONPPathEntryTypeDot || needsFullSourceInfo)
+ return false;
+ path.last().m_type = JSONPPathEntryTypeCall;
+ entry = path.last();
+ goto startJSON;
+ }
default:
return false;
}
path.append(entry);
tokenType = m_lexer.next();
}
+ startJSON:
m_lexer.next();
results.append(JSONPData());
results.last().m_value.set(m_exec->globalData(), parse(StartParseExpression));
if (!results.last().m_value)
return false;
results.last().m_path.swap(path);
+ if (entry.m_type == JSONPPathEntryTypeCall) {
+ if (m_lexer.currentToken().type != TokRParen)
+ return false;
+ m_lexer.next();
+ }
if (m_lexer.currentToken().type != TokSemi)
break;
m_lexer.next();
@@ -150,11 +163,11 @@
case '(':
token.type = TokLParen;
token.end = ++m_ptr;
- return TokLBracket;
+ return TokLParen;
case ')':
token.type = TokRParen;
token.end = ++m_ptr;
- return TokRBracket;
+ return TokRParen;
case '{':
token.type = TokLBrace;
token.end = ++m_ptr;
Modified: trunk/Source/_javascript_Core/runtime/LiteralParser.h (91870 => 91871)
--- trunk/Source/_javascript_Core/runtime/LiteralParser.h 2011-07-27 21:50:57 UTC (rev 91870)
+++ trunk/Source/_javascript_Core/runtime/LiteralParser.h 2011-07-27 21:55:40 UTC (rev 91871)
@@ -66,7 +66,8 @@
enum JSONPPathEntryType {
JSONPPathEntryTypeDeclare, // var pathEntryName = JSON
JSONPPathEntryTypeDot, // <prior entries>.pathEntryName = JSON
- JSONPPathEntryTypeLookup // <prior entries>[pathIndex] = JSON
+ JSONPPathEntryTypeLookup, // <prior entries>[pathIndex] = JSON
+ JSONPPathEntryTypeCall // <prior entries>(JSON)
};
struct JSONPPathEntry {
@@ -80,7 +81,7 @@
Strong<Unknown> m_value;
};
- bool tryJSONPParse(Vector<JSONPData>&);
+ bool tryJSONPParse(Vector<JSONPData>&, bool needsFullSourceInfo);
private:
enum ParserState { StartParseObject, StartParseArray, StartParseExpression,