Commit 5de71312 authored by jcivelli@chromium.org's avatar jcivelli@chromium.org

Make sure MHTML documents use the domain of the MHTML file.

https://bugs.webkit.org/show_bug.cgi?id=72445

Reviewed by Adam Barth.

Source/WebCore:

* dom/Document.h:
(WebCore::Document::setBaseURL):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::receivedFirstData):

LayoutTests:

* mhtml/check_domain-expected.txt: Added.
* mhtml/check_domain.mht: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@100550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 533a1fe0
2011-11-16 Jay Civelli <jcivelli@chromium.org>
Make sure MHTML documents use the domain of the MHTML file.
https://bugs.webkit.org/show_bug.cgi?id=72445
Reviewed by Adam Barth.
* mhtml/check_domain-expected.txt: Added.
* mhtml/check_domain.mht: Added.
2011-11-11 Adrienne Walker <enne@google.com>
[chromium] Expose mock scrollbars to window.internals
This is a very simple page
Very basic page.
PASS
From: <Saved by UnMHT>
Subject: =?iso-2022-jp?B?QSBzaW1wbGUgcGFnZQ==?=
Date: Wed, May 11 2011 15:36:36 GMT-0700
MIME-Version: 1.0
Content-Type: multipart/related;
boundary="----=_NextPart_000_0000_87206557.D2C008B0";
type="text/html"
------=_NextPart_000_0000_87206557.D2C008B0
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/simple_page.html
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Diso-8859-1">
<title>A simple page</title>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
window.onload = function() {
var span=3Ddocument.createElement("span");
if (window.location !=3D 'http://localhost/simple_page.html' &&
document.domain !=3D 'localhost') {
span.innerHTML = "PASS";
} else {
span.innerHTML = "FAIL window.location=" + window.location +
" document.domain=" + document.domain;
}
document.getElementById('locDiv').appendChild(span);
layoutTestController.notifyDone();
}
</script>
<base href=3D"http://localhost/"></base></head><body>
<h1>This is a very simple page</h1>
Very <b>basic</b> page.
<div id=3D'locDiv'></div>
</body></html>
------=_NextPart_000_0000_87206557.D2C008B0--
2011-11-16 Jay Civelli <jcivelli@chromium.org>
Make sure MHTML documents use the domain of the MHTML file.
https://bugs.webkit.org/show_bug.cgi?id=72445
Reviewed by Adam Barth.
* dom/Document.h:
(WebCore::Document::setBaseURL):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::receivedFirstData):
2011-11-16 Julien Chaffraix <jchaffraix@webkit.org>
Update supported display list after -webkit-grid and -webkit-inline-grid addition
......@@ -2403,12 +2403,16 @@ void Document::updateBaseURL()
// DOM 3 Core: When the Document supports the feature "HTML" [DOM Level 2 HTML], the base URI is computed using
// first the value of the href attribute of the HTML BASE element if any, and the value of the documentURI attribute
// from the Document interface otherwise.
if (m_baseElementURL.isEmpty()) {
if (!m_baseElementURL.isEmpty())
m_baseURL = m_baseElementURL;
else if (!m_baseURLOverride.isEmpty())
m_baseURL = m_baseURLOverride;
else {
// The documentURI attribute is an arbitrary string. DOM 3 Core does not specify how it should be resolved,
// so we use a null base URL.
m_baseURL = KURL(KURL(), documentURI());
} else
m_baseURL = m_baseElementURL;
}
if (!m_baseURL.isValid())
m_baseURL = KURL();
......@@ -2418,6 +2422,12 @@ void Document::updateBaseURL()
m_mappedElementSheet->setFinalURL(m_baseURL);
}
void Document::setBaseURLOverride(const KURL& url)
{
m_baseURLOverride = url;
updateBaseURL();
}
void Document::processBaseElement()
{
// Find the first href attribute in a base element and the first target attribute in a base element.
......
......@@ -608,6 +608,8 @@ public:
void setURL(const KURL&);
const KURL& baseURL() const { return m_baseURL; }
void setBaseURLOverride(const KURL&);
const KURL& baseURLOverride() const { return m_baseURLOverride; }
const String& baseTarget() const { return m_baseTarget; }
void processBaseElement();
......@@ -1186,6 +1188,7 @@ private:
// Document URLs.
KURL m_url; // Document.URL: The URL from which this document was retrieved.
KURL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
KURL m_baseURLOverride; // An alternative base URL that takes precedence ove m_baseURL (but not m_baseElementURL).
KURL m_baseElementURL; // The URL set by the <base> element.
KURL m_cookieURL; // The URL to use for cookie access.
KURL m_firstPartyForCookies; // The policy URL for third-party cookie blocking.
......
......@@ -563,7 +563,7 @@ void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects, boo
void FrameLoader::receivedFirstData()
{
KURL workingURL = activeDocumentLoader()->documentURL();
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
#if ENABLE(WEB_ARCHIVE)
// FIXME: The document loader, not the frame loader, should be in charge of loading web archives.
// Once this is done, we can just make DocumentLoader::documentURL() return the right URL
// based on whether it has a non-null archive or not.
......@@ -576,7 +576,15 @@ void FrameLoader::receivedFirstData()
dispatchDidCommitLoad();
dispatchDidClearWindowObjectsInAllWorlds();
#if ENABLE(MHTML)
if (m_archive) {
// The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
// relative URLs are resolved properly.
m_frame->document()->setBaseURLOverride(m_archive->mainResource()->url());
}
#endif
if (m_documentLoader) {
StringWithDirection ptitle = m_documentLoader->title();
// If we have a title let the WebView know about it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment