Bug 235338 - rekonq does not show the actual page source but a changed version
Summary: rekonq does not show the actual page source but a changed version
Status: RESOLVED FIXED
Alias: None
Product: rekonq
Classification: Applications
Component: general (show other bugs)
Version: latest git snapshot
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Andrea Diamantini
URL:
Keywords:
Depends on:
Blocks: 237890
  Show dependency treegraph
 
Reported: 2010-04-25 12:20 UTC by Tobias Leupold
Modified: 2010-09-04 10:01 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Leupold 2010-04-25 12:20:52 UTC
Version:           0.4.0 (using KDE 4.4.2)
OS:                Linux
Installed from:    Gentoo Packages

When viewing the source text of a web page, rekonq does not show what the server delivered but a changed version.

I tried it a page from one of my homepages (http://dr-leupold.de/vita.php); Konqueror, Firefox and Opera all show exactly the very same page source (with only the DC.date meta tag of the header differing for obvious reasons) which is identical with the HTML the PHP script generates.

In contrast, rekonq changes all kind of stuff when viewing the page source:

All over the text, newlines are added or left out

The <?xml tag is left out

The <!DOCTYPE tag is displayed in one line, the <header> tag is appended

All the necessary closing slashes (like for <meta ... /> or <img ... />) are left out

A <tbody> tag is inserted in the table

I really think rekonq should display the actual source text instead of a changed version!
Comment 1 Panagiotis Papadopoulos 2010-04-25 21:58:15 UTC
I can confirm this behaviour.
In Konqueror with the kdewebkit KPart it shows the same source as the KHTML one, so this most likely is a rekonq specific issue.

Thanks for the report
Comment 2 Nikhil Marathe 2010-05-20 13:13:06 UTC
The solution is always to use KRun::runUrl() to re-fetch the file from the server and display it, since WebKit apparently generates its source rather than keeping what it originally received. But this introduces issues of double loading, with regard to bandwidth.

The alternative would be to set the link delegation policy for webkit to do nothing, manually load the URL using KIO and use setHtml(). Perhaps then the file could be cached.

But which choice to make?
Comment 3 Tobias Leupold 2010-05-20 13:25:09 UTC
I'm not a rekonq coder, but I would cache the original source file if Webkit changes the original source, as the source could have already changed when the user requests it. Just think of the DC.date header of my homepage.
Comment 4 Andrea Diamantini 2010-05-25 03:23:54 UTC
commit face04758de427df55b58ce47d0a39628b6b96fa
Author: Andrea Diamantini <adjam7@gmail.com>
Date:   Tue May 25 01:38:37 2010 +0200

    Show actual page source
    
    BUG:235338

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d14f225..1b36e6d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -951,26 +951,8 @@ void MainWindow::viewPageSource()
     if (!currentTab())
         return;
 
-    KUrl url(currentTab()->url());
-    bool isTempFile = false;
-    if (!url.isLocalFile())
-    {
-        KTemporaryFile sourceFile;
-
-        /// TODO: autochoose tempfile suffix
-        sourceFile.setSuffix(QString(".html"));
-        sourceFile.setAutoRemove(false);
-
-        if (sourceFile.open())
-        {
-            sourceFile.write(currentTab()->page()->mainFrame()->toHtml().toUtf8());
-
-            url = KUrl();
-            url.setPath(sourceFile.fileName());
-            isTempFile = true;
-        }
-    }
-    KRun::runUrl(url, QL1S("text/plain"), this, isTempFile);
+    KUrl url = currentTab()->url();
+    KRun::runUrl(url, QL1S("text/plain"), this, false);
 }
 
 
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index c2f1d0e..07b40ba 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -271,4 +271,3 @@ UrlSearchItem UrlResolver::privilegedItem(UrlSearchList* list)
     }
     return UrlSearchItem();
 }
-