summaryrefslogtreecommitdiff
path: root/src/protocolhandler.cpp
diff options
context:
space:
mode:
authorNikhil Marathe <nsm.nikhil@gmail.com>2010-05-16 15:40:40 +0530
committerNikhil Marathe <nsm.nikhil@gmail.com>2010-05-16 15:41:43 +0530
commit720d51efb2db7fe36cb7f9177522feb0967e15ee (patch)
tree742ae646bd928921abba2f08f712f9a6b951174c /src/protocolhandler.cpp
parentSVN_SILENT made messages (.desktop file) (diff)
downloadrekonq-720d51efb2db7fe36cb7f9177522feb0967e15ee.tar.xz
Added support for javascript:<code> so that bookmarklets work
BUG: 227422
Diffstat (limited to 'src/protocolhandler.cpp')
-rw-r--r--src/protocolhandler.cpp14
1 files changed, 12 insertions, 2 deletions
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:<code here> 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;