From 720d51efb2db7fe36cb7f9177522feb0967e15ee Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Sun, 16 May 2010 15:40:40 +0530 Subject: Added support for javascript: so that bookmarklets work BUG: 227422 --- src/protocolhandler.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index d710c24c..63bc640d 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -93,8 +93,18 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra if (_url.protocol() == QL1S("javascript")) { QString scriptSource = _url.authority(); - if(scriptSource.isEmpty()) - return false; + if(scriptSource.isEmpty()) { + // if javascript: then authority() returns + // an empty string. Extract the source manually +// Use the prettyUrl() since that is unencoded + + // 11 is length of 'javascript:' + // fromPercentEncoding() is used to decode all the % encoded + // characters to normal, so that it is treated as valid javascript + scriptSource = QUrl::fromPercentEncoding(_url.url().mid(11).toAscii()); + if(scriptSource.isEmpty()) + return false; + } QVariant result = frame->evaluateJavaScript(scriptSource); return true; -- cgit v1.2.1