Commit cc025d83 authored by adele's avatar adele

WebCore:

        Reviewed by Kevin M.

        WebCore part of fix for <rdar://problem/5095515> VitalSource Bookshelf should not pass return statements into stringByEvaluatingJavaScriptFromString

        * page/mac/WebCoreFrameBridge.mm: (-[WebCoreFrameBridge stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
        Convert return value to a string.  This matches the behavior in Safari 2.0.

WebKit:

        Reviewed by Kevin M.

        WebKit part of fix for <rdar://problem/5095515> VitalSource Bookshelf should not pass return statements into stringByEvaluatingJavaScriptFromString

        Added an app specific workaround for VitalSource Bookshelf that strips "return" from the beginning of their script strings.  We used to allow this
        but now we throw a JavaScript exception for return statements that aren't in functions.

        Filed this evangelism bug so we can notify VitalSource of the problem:
        <rdar://problem/5095515> VitalSource Bookshelf should not pass return statements into stringByEvaluatingJavaScriptFromString

        * WebView/WebView.mm: (-[WebView stringByEvaluatingJavaScriptFromString:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20555 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 16c9b5f7
2007-03-28 Adele Peterson <adele@apple.com>
Reviewed by Kevin M.
WebCore part of fix for <rdar://problem/5095515> VitalSource Bookshelf should not pass return statements into stringByEvaluatingJavaScriptFromString
* page/mac/WebCoreFrameBridge.mm: (-[WebCoreFrameBridge stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
Convert return value to a string. This matches the behavior in Safari 2.0.
2007-03-28 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
......
......@@ -687,10 +687,10 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
{
m_frame->loader()->createEmptyDocument();
JSValue* result = m_frame->loader()->executeScript(0, string, forceUserGesture);
if (!result || !result->isString())
if (!result)
return 0;
JSLock lock;
return String(result->getString());
return String(result->isString() ? result->getString() : result->toString(m_frame->scriptProxy()->interpreter()->globalExec()));
}
- (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)string
......
2007-03-28 Adele Peterson <adele@apple.com>
Reviewed by Kevin M.
WebKit part of fix for <rdar://problem/5095515> VitalSource Bookshelf should not pass return statements into stringByEvaluatingJavaScriptFromString
Added an app specific workaround for VitalSource Bookshelf that strips "return" from the beginning of their script strings. We used to allow this
but now we throw a JavaScript exception for return statements that aren't in functions.
Filed this evangelism bug so we can notify VitalSource of the problem:
<rdar://problem/5095515> VitalSource Bookshelf should not pass return statements into stringByEvaluatingJavaScriptFromString
* WebView/WebView.mm: (-[WebView stringByEvaluatingJavaScriptFromString:]):
2007-03-27 John Sullivan <sullivan@apple.com>
Reviewed by Tim
......
......@@ -2099,6 +2099,14 @@ NS_ENDHANDLER
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
{
// FIXME: We can remove this workaround for VitalSource Bookshelf when they update
// their code so that it no longer calls stringByEvaluatingJavaScriptFromString with a return statement.
// Return statements are only valid in a function. See <rdar://problem/5095515> for the evangelism bug.
if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.vitalsource.bookshelf"]) {
NSRange returnStringRange = [script rangeOfString:@"return "];
if (returnStringRange.length != 0 && returnStringRange.location == 0)
script = [script substringFromIndex: returnStringRange.location + returnStringRange.length];
}
return [[[self mainFrame] _bridge] stringByEvaluatingJavaScriptFromString:script];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment