diff options
author | Chris Double <chris.double@double.co.nz> | 2015-03-12 23:41:09 +1300 |
---|---|---|
committer | Chris Double <chris.double@double.co.nz> | 2015-03-17 11:06:44 +1300 |
commit | 82c52a7a1c2d1fcdad797fc73564d6f624650473 (patch) | |
tree | 1ec6d7043fb699139968a2a293fc87fb923bc086 /components/script/parse/html.rs | |
parent | f5ddbcf19fcd477dee61d6c03434ef7cfca188bf (diff) | |
download | servo-82c52a7a1c2d1fcdad797fc73564d6f624650473.tar.gz servo-82c52a7a1c2d1fcdad797fc73564d6f624650473.zip |
Implement view-source protocol. Fixes #4181.
This follows the recommendation from issue #4181. A handler
for 'view-source' delegates to the HTTP loader. In that
loader I check for view-source, adjust the URL to be the
URL to be viewed and modify the Content-Type header to be
text/plain.
This doesn't actually result in the source being
viewed as rendering text/plain is not yet implemented.
Diffstat (limited to 'components/script/parse/html.rs')
-rw-r--r-- | components/script/parse/html.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index 6da3dac1ec8..c4417459f96 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -190,6 +190,20 @@ pub fn parse_html(document: JSRef<Document>, let page = format!("<html><body><img src='{}' /></body></html>", url.serialize()); parser.parse_chunk(page); }, + Some((ref t, ref st)) if t.as_slice().eq_ignore_ascii_case("text") && + st.as_slice().eq_ignore_ascii_case("plain") => { + // FIXME: When servo/html5ever#109 is fixed remove <plaintext> usage and + // replace with fix from that issue. + + // text/plain documents require setting the tokenizer into PLAINTEXT mode. + // This is done by using a <plaintext> element as the html5ever tokenizer + // provides no other way to change to that state. + // Spec for text/plain handling is: + // https://html.spec.whatwg.org/multipage/browsers.html#read-text + let page = format!("<pre>\u{000A}<plaintext>"); + parser.parse_chunk(page); + parse_progress(&parser, url, &load_response); + }, _ => { for msg in load_response.progress_port.iter() { match msg { |