summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-05-16 22:49:59 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-05-16 22:49:59 +0200
commit9fda939f4d67054e3deb20c4e410ed58744c2ba0 (patch)
tree455f96e2d574ea1a1e3ae6d1c625d4b37e5780f5 /src
parentMerge commit 'refs/merge-requests/2262' of git://gitorious.org/rekonq/mainlin... (diff)
parentAdded support for javascript:<code> so that bookmarklets work (diff)
downloadrekonq-9fda939f4d67054e3deb20c4e410ed58744c2ba0.tar.xz
Merge commit 'refs/merge-requests/2263' of git://gitorious.org/rekonq/mainline into m2263
Diffstat (limited to 'src')
-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;