Changeset 41045 in webkit for trunk/JavaScriptCore
- Timestamp:
- Feb 17, 2009, 4:14:30 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r41036 r41045 1 2009-02-17 Geoffrey Garen <[email protected]> 2 3 Reviewed by Sam Weinig. 4 5 Fixed <rdar://problem/6595040> REGRESSION: http://www.amnestyusa.org/ 6 fails to load. 7 8 amnestyusa.org uses the Optimist JavaScript library, which adds event 9 listeners by concatenating string-ified functions. This is only sure to 10 be syntactically valid if the string-ified functions end in semicolons. 11 12 * parser/Lexer.cpp: 13 (JSC::Lexer::isWhiteSpace): 14 * parser/Lexer.h: 15 (JSC::Lexer::isWhiteSpace): 16 (JSC::Lexer::isLineTerminator): Added some helper functions for examining 17 whitespace. 18 19 * runtime/FunctionPrototype.cpp: 20 (JSC::appendSemicolonIfNeeded): 21 (JSC::functionProtoFuncToString): When string-ifying a function, insert 22 a semicolon in the last non-whitespace position, if one doesn't already exist. 23 1 24 2009-02-16 Oliver Hunt <[email protected]> 2 25 -
trunk/JavaScriptCore/parser/Lexer.cpp
r40501 r41045 34 34 #include <wtf/ASCIICType.h> 35 35 #include <wtf/Assertions.h> 36 #include <wtf/unicode/Unicode.h>37 36 38 37 using namespace WTF; … … 590 589 bool Lexer::isWhiteSpace() const 591 590 { 592 return m_current == '\t' || m_current == 0x0b || m_current == 0x0c || isSeparatorSpace(m_current);591 return isWhiteSpace(m_current); 593 592 } 594 593 -
trunk/JavaScriptCore/parser/Lexer.h
r40214 r41045 28 28 #include "SourceCode.h" 29 29 #include <wtf/Vector.h> 30 #include <wtf/unicode/Unicode.h> 30 31 31 32 namespace JSC { … … 90 91 void clear(); 91 92 SourceCode sourceCode(int openBrace, int closeBrace, int firstLine) { return SourceCode(m_source->provider(), openBrace, closeBrace + 1, firstLine); } 93 94 static inline bool isWhiteSpace(int ch) 95 { 96 return ch == '\t' || ch == 0x0b || ch == 0x0c || WTF::Unicode::isSeparatorSpace(ch); 97 } 98 99 static inline bool isLineTerminator(int ch) 100 { 101 return ch == '\r' || ch == '\n' || ch == 0x2028 || ch == 0x2029; 102 } 92 103 93 104 private: -
trunk/JavaScriptCore/runtime/FunctionPrototype.cpp
r40046 r41045 64 64 // Functions 65 65 66 // Compatibility hack for the Optimost JavaScript library. (See <rdar://problem/6595040>.) 67 static inline void insertSemicolonIfNeeded(UString& functionBody) 68 { 69 ASSERT(functionBody[0] == '{'); 70 ASSERT(functionBody[functionBody.size() - 1] == '}'); 71 72 for (size_t i = functionBody.size() - 2; i > 0; --i) { 73 UChar ch = functionBody[i]; 74 if (!Lexer::isWhiteSpace(ch) && !Lexer::isLineTerminator(ch)) { 75 if (ch != ';') 76 functionBody = functionBody.substr(0, i + 1) + ";" + functionBody.substr(i + 1, functionBody.size() - (i + 1)); 77 return; 78 } 79 } 80 } 81 66 82 JSValuePtr functionProtoFuncToString(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList&) 67 83 { 68 84 if (thisValue.isObject(&JSFunction::info)) { 69 85 JSFunction* function = asFunction(thisValue); 70 return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + function->body()->paramString() + ") " + function->body()->toSourceString()); 86 UString functionBody = function->body()->toSourceString(); 87 insertSemicolonIfNeeded(functionBody); 88 return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + function->body()->paramString() + ") " + functionBody); 71 89 } 72 90
Note:
See TracChangeset
for help on using the changeset viewer.