summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tests/link_test.html7
-rw-r--r--src/webpage.cpp26
-rw-r--r--src/webpage.h1
3 files changed, 23 insertions, 11 deletions
diff --git a/src/tests/link_test.html b/src/tests/link_test.html
index 7dd1470d..5ca3cd41 100644
--- a/src/tests/link_test.html
+++ b/src/tests/link_test.html
@@ -135,6 +135,13 @@
<td><a href="http://ads.cnn.com/" target="_blank">link</a></td>
</tr>
+
+<tr>
+<td>http://ja.wikipedia.org/wiki/特別:最近の更新</td>
+<td>KGet import links with particular encoding</td>
+<td><a href="http://ja.wikipedia.org/wiki/特別:最近の更新">link</a></td>
+</tr>
+
<tr>
<td></td>
<td></td>
diff --git a/src/webpage.cpp b/src/webpage.cpp
index ce2d5e40..b5318874 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -72,7 +72,7 @@
WebPage::WebPage(QObject *parent)
- : KWebPage(parent, KWalletIntegration)
+ : KWebPage(parent, KWalletIntegration)
{
setForwardUnsupportedContent(true);
@@ -87,9 +87,10 @@ WebPage::WebPage(QObject *parent)
// Web Plugin Factory
setPluginFactory(new WebPluginFactory(this));
-
- connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+ // managing errors
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+ // handling load & content
connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
@@ -121,8 +122,6 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
return false;
}
- m_requestedUrl = request.url();
-
return KWebPage::acceptNavigationRequest(frame, request, type);
}
@@ -218,7 +217,10 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
if( reply->error() == QNetworkReply::ContentAccessDenied )
return;
- if( reply->url() != m_requestedUrl ) // prevent favicon loading
+ // don't bother on elements loading errors: we'll manage just
+ // main url page ones
+ WebView *v = qobject_cast<WebView *>(view());
+ if( reply->url() != v->url() )
return;
if( reply->error() == QNetworkReply::ContentNotFoundError )
@@ -334,18 +336,22 @@ void WebPage::downloadRequest(const QNetworkRequest &request)
void WebPage::downloadAllContentsWithKGet()
{
- QList<QString> contentList;
+ QSet<QString> contents;
+ KUrl baseUrl( currentFrame()->url() );
+ KUrl relativeUrl;
QWebElementCollection images = mainFrame()->documentElement().findAll("img");
foreach(QWebElement img, images)
{
- contentList.append(img.attribute("src"));
+ relativeUrl.setEncodedUrl(img.attribute("src").toUtf8(),KUrl::TolerantMode);
+ contents << baseUrl.resolved(relativeUrl).toString();
}
QWebElementCollection links = mainFrame()->documentElement().findAll("a");
foreach(QWebElement link, links)
{
- contentList.append(link.attribute("href"));
+ relativeUrl.setEncodedUrl(link.attribute("href").toUtf8(),KUrl::TolerantMode);
+ contents << baseUrl.resolved(relativeUrl).toString();
}
if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
@@ -353,5 +359,5 @@ void WebPage::downloadAllContentsWithKGet()
KToolInvocation::kdeinitExecWait("kget");
}
QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
- kget.call("importLinks", QVariant(contentList));
+ kget.call("importLinks", QVariant(contents.toList()));
}
diff --git a/src/webpage.h b/src/webpage.h
index bbaa0f63..f76fd334 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -77,7 +77,6 @@ private slots:
private:
QString errorPage(QNetworkReply *);
- QUrl m_requestedUrl;
ProtocolHandler m_protHandler;
};