Commit 58267196 authored by ap@apple.com's avatar ap@apple.com

REGRESSION: Downloaded file name fallback encodings are not set correctly

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

Reviewed by Adam Barth.

Source/WebCore:

Tests: http/tests/download/default-encoding.html
       http/tests/download/form-submission-result.html
       http/tests/download/inherited-encoding.html
       http/tests/download/literal-utf-8.html

* loader/DocumentWriter.cpp:
* loader/DocumentWriter.h:
Removed deprecatedFrameEncoding. Due to changes in Document::encoding behavior, it can now
be used in its place.

* loader/FrameLoader.cpp: (WebCore::FrameLoader::addExtraFieldsToRequest): Instead of hunting
down a correct loader (and active one is not always correct any more), just use opening document's
encoding.

LayoutTests:

* http/tests/download/default-encoding-expected.txt: Added.
* http/tests/download/default-encoding.html: Added.
* http/tests/download/inherited-encoding-expected.txt: Added.
* http/tests/download/inherited-encoding.html: Added.
* http/tests/download/literal-utf-8-expected.txt: Added.
* http/tests/download/literal-utf-8.html: Added.
* http/tests/download/resources/literal-koi8-r.php: Added.
* http/tests/download/resources/literal-utf-8.php: Added.
* http/tests/download/inherited-encoding-form-submission-result-expected.txt: Added.
* http/tests/download/inherited-encoding-form-submission-result.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a625ad3a
2012-01-23 Alexey Proskuryakov <ap@apple.com>
REGRESSION: Downloaded file name fallback encodings are not set correctly
https://bugs.webkit.org/show_bug.cgi?id=76862
Reviewed by Adam Barth.
* http/tests/download/default-encoding-expected.txt: Added.
* http/tests/download/default-encoding.html: Added.
* http/tests/download/inherited-encoding-expected.txt: Added.
* http/tests/download/inherited-encoding.html: Added.
* http/tests/download/literal-utf-8-expected.txt: Added.
* http/tests/download/literal-utf-8.html: Added.
* http/tests/download/resources/literal-koi8-r.php: Added.
* http/tests/download/resources/literal-utf-8.php: Added.
* http/tests/download/inherited-encoding-form-submission-result-expected.txt: Added.
* http/tests/download/inherited-encoding-form-submission-result.html: Added.
2012-01-23 Ojan Vafai <ojan@chromium.org>
Implement flex-pack:distribute
Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-koi8-r.php with navigation type 'link clicked' originating from #text > A > BODY > HTML > #document
Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
Click Me
<meta charset="utf-8">
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.overridePreference("WebKitDefaultTextEncodingName", "koi8-r");
layoutTestController.setCustomPolicyDelegate(true, true);
layoutTestController.waitForPolicyDelegate();
}
</script>
<p>Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).</p>
<a href="resources/literal-koi8-r.php" id=link>Click Me</a>
<script>
if (window.eventSender) {
var link = document.getElementById("link");
eventSender.mouseMoveTo(link.offsetLeft + 2,
link.offsetTop + 2);
eventSender.mouseDown();
eventSender.mouseUp();
}
</script>
Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-koi8-r.php with navigation type 'link clicked' originating from #text > A > BODY > HTML > #document
Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
Click Me
Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-koi8-r.php? with navigation type 'form submitted'
Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
<meta charset="koi8-r">
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.setCustomPolicyDelegate(true, true);
layoutTestController.waitForPolicyDelegate();
}
</script>
<p>Downloaded file name should be "SUSS.txt" (letters "CCE" are Cyrillic).</p>
<form action="resources/literal-koi8-r.php">
</form>
<script>
document.forms[0].submit();
</script>
<meta charset="koi8-r">
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.setCustomPolicyDelegate(true, true);
layoutTestController.waitForPolicyDelegate();
}
</script>
<p>Downloaded file name should be "SUSS.txt" (letters "CCE" are Cyrillic).</p>
<a href="resources/literal-koi8-r.php" id=link>Click Me</a>
<script>
if (window.eventSender) {
var link = document.getElementById("link");
eventSender.mouseMoveTo(link.offsetLeft + 2,
link.offsetTop + 2);
eventSender.mouseDown();
eventSender.mouseUp();
}
</script>
Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-utf-8.php with navigation type 'other'
Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
<meta charset="koi8-r"> <!-- Page charset should be ignored -->
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.setCustomPolicyDelegate(true, true);
}
</script>
<p>Downloaded file name should be "SUSS.txt" (letters "CCE" are Cyrillic).</p>
<iframe src="resources/literal-utf-8.php"></iframe>
File mode changed from 100755 to 100644
<?php
header("Content-Disposition: attachment; filename=SU\xf3\xf3\xe5SS.txt");
header("Content-Type: text/plain; charset=windows-1251"); // Content-Type charset does not affect header charset.
?>
Test file content.
<?php
header("Content-Disposition: attachment; filename=SU\xd0\xa1\xd0\xa1\xd0\x95SS.txt");
header("Content-Type: text/plain; charset=koi8-r"); // Content-Type charset does not affect header charset.
?>
Test file content.
2012-01-23 Alexey Proskuryakov <ap@apple.com>
REGRESSION: Downloaded file name fallback encodings are not set correctly
https://bugs.webkit.org/show_bug.cgi?id=76862
Reviewed by Adam Barth.
Tests: http/tests/download/default-encoding.html
http/tests/download/form-submission-result.html
http/tests/download/inherited-encoding.html
http/tests/download/literal-utf-8.html
* loader/DocumentWriter.cpp:
* loader/DocumentWriter.h:
Removed deprecatedFrameEncoding. Due to changes in Document::encoding behavior, it can now
be used in its place.
* loader/FrameLoader.cpp: (WebCore::FrameLoader::addExtraFieldsToRequest): Instead of hunting
down a correct loader (and active one is not always correct any more), just use opening document's
encoding.
2012-01-23 Ojan Vafai <ojan@chromium.org>
Implement flex-pack:distribute
......@@ -241,21 +241,6 @@ void DocumentWriter::setEncoding(const String& name, bool userChosen)
m_encodingWasChosenByUser = userChosen;
}
String DocumentWriter::deprecatedFrameEncoding() const
{
Document* document = m_frame->document();
if (!document || document->url().isEmpty())
return m_encoding;
if (m_encodingWasChosenByUser && !m_encoding.isEmpty())
return m_encoding;
if (m_decoder && m_decoder->encoding().isValid())
return m_decoder->encoding().name();
return String();
}
void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation()
{
ASSERT(!m_parser->isStopped());
......
......@@ -59,11 +59,6 @@ public:
void setEncoding(const String& encoding, bool userChosen);
// FIXME: It's really unforunate to need to expose this piece of state.
// I suspect a better design is to disentangle user-provided encodings,
// default encodings, and the decoding we're currently using.
String deprecatedFrameEncoding() const;
const String& mimeType() const { return m_mimeType; }
void setMIMEType(const String& type) { m_mimeType = type; }
......
......@@ -2585,9 +2585,8 @@ void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp
addHTTPOriginIfNeeded(request, String());
// Always try UTF-8. If that fails, try frame encoding (if any) and then the default.
// For a newly opened frame with an empty URL, encoding() should not be used, because this methods asks decoder, which uses ISO-8859-1.
Settings* settings = m_frame->settings();
request.setResponseContentDispositionEncodingFallbackArray("UTF-8", activeDocumentLoader()->writer()->deprecatedFrameEncoding(), settings ? settings->defaultTextEncodingName() : String());
request.setResponseContentDispositionEncodingFallbackArray("UTF-8", m_frame->document()->encoding(), settings ? settings->defaultTextEncodingName() : String());
}
void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const String& origin)
......
......@@ -609,6 +609,7 @@ static void resetDefaultsToConsistentValues()
[preferences setDefaultFontSize:16];
[preferences setDefaultFixedFontSize:13];
[preferences setMinimumFontSize:0];
[preferences setDefaultTextEncodingName:@"ISO-8859-1"];
[preferences setJavaEnabled:NO];
[preferences setJavaScriptEnabled:YES];
[preferences setEditableLinkBehavior:WebKitEditableLinkOnlyLiveWithShiftKey];
......
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