From b9d853376008b9439f5d0ac60d23580df7bd7ad5 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 17 Oct 2014 15:12:35 +0200 Subject: [PATCH] Don't crash on invalid utf-8 in the HTML parser. This was regressed by the html5ever landing. --- components/script/parse/html.rs | 2 +- tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini | 4 +++- .../metadata/XMLHttpRequest/send-content-type-string.htm.ini | 3 --- .../metadata/XMLHttpRequest/send-entity-body-document.htm.ini | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 tests/wpt/metadata/XMLHttpRequest/send-content-type-string.htm.ini diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index 829d5d0c40b..933202e81f6 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -496,7 +496,7 @@ pub fn parse_html(page: &Page, match msg { Payload(data) => { // FIXME: use Vec (html5ever #34) - let data = String::from_utf8(data).unwrap(); + let data = UTF_8.decode(data.as_slice(), DecodeReplace).unwrap(); parser.tokenizer().borrow_mut().feed(data); } Done(Err(err)) => { diff --git a/tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini b/tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini index fbfed5cf272..f1d83359558 100644 --- a/tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini +++ b/tests/wpt/metadata/XMLHttpRequest/open-url-encoding.htm.ini @@ -1,3 +1,5 @@ [open-url-encoding.htm] type: testharness - expected: CRASH + [XMLHttpRequest: open() - URL encoding] + expected: FAIL + diff --git a/tests/wpt/metadata/XMLHttpRequest/send-content-type-string.htm.ini b/tests/wpt/metadata/XMLHttpRequest/send-content-type-string.htm.ini deleted file mode 100644 index 5cd8ba36901..00000000000 --- a/tests/wpt/metadata/XMLHttpRequest/send-content-type-string.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[send-content-type-string.htm] - type: testharness - expected: CRASH diff --git a/tests/wpt/metadata/XMLHttpRequest/send-entity-body-document.htm.ini b/tests/wpt/metadata/XMLHttpRequest/send-entity-body-document.htm.ini index d3c5b4afeaf..d35f507ee10 100644 --- a/tests/wpt/metadata/XMLHttpRequest/send-entity-body-document.htm.ini +++ b/tests/wpt/metadata/XMLHttpRequest/send-entity-body-document.htm.ini @@ -1,3 +1,3 @@ [send-entity-body-document.htm] type: testharness - expected: CRASH + expected: TIMEOUT