Bug 29560 - [Qt] QWebFrame.setHtml() doesn't resolve relative files references in HTML
Summary: [Qt] QWebFrame.setHtml() doesn't resolve relative files references in HTML
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2009-09-21 08:01 PDT by Tor Arne Vestbø
Modified: 2014-02-03 03:15 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tor Arne Vestbø 2009-09-21 08:01:22 PDT
This bug report originated from Nokia internal issue QT-1096


--- Comments ---

Version: 4.5.1

Platform: MacOSX
Mac OS 10.5.6 on a Unibody Macbook (Intel Core 2 Duo)

Compiler: GCC

Short description: QWebFrame.setHtml() doesn't resolve relative files references in HTML

Did:
I use QWebPage::mainFrame()->setHtml(html,QUrl::fromLocalFile("myBasedDir")) to set the HTML content for the Frame. The HTML markup contains references to external files (css, js). The paths of these files are relative to "myBaseDir" set as baseUrl.

Expected to see:
Correct rendering of HTML markup including resolution of externally referenced resources (css, js)

Got instead:
All HTML markup and inline css and js are rendered/executed correctly. No externally linked resources are incorporated.

More details:
The same code works using Qt 4.5.1 on Windows XP
Comment 1 Kent Hansen 2010-03-16 05:02:28 PDT
Reproduced with r55986 on Linux. I can't even get this to work when using an absolute base URL.
Comment 2 Jenya Brodskaia 2010-11-09 10:31:57 PST
The test case would help a lot.
Comment 3 Jenya Brodskaia 2010-11-15 08:48:27 PST
The test case is missing, so I created this one according to the description above:

 	QWebView *myView = new QWebView();
 	QWebPage *myPage = myView->page();

 	QString html = "<html>RED APPLE    <img src=\"apple.gif\"/></html>";
 	QUrl url = QUrl::fromLocalFile("/home/jb_test/myBaseDir/"); // Works. Valid file:/// url is constructed 
        QUrl url1("file:///home/jb_test/myBaseDir/"); // Works. 
        QUrl url2 = QUrl::fromLocalFile("myBaseDir/"); // Does not work. 

	myPage->mainFrame()->setHtml(html, url);    
	//myPage->mainFrame()->setHtml(html, url1); 
	//myPage->mainFrame()->setHtml(html, url2); 
	myView->show();

The issue is reproducible, but it is not a bug. 
QUrl::fromLocalFile("myBaseDir/")  does not get resolved to the valid url, but if you provide a full file path - it does.
See http://doc.trolltech.com/4.7/qurl.html. The documentation does not suggest that relative path may be used in QUrl::fromLocalFile.
Comment 4 Jocelyn Turcotte 2014-02-03 03:15:47 PST
=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.