aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/html/hubbub_html_parser.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2014-09-13 11:22:29 -0400
committerJosh Matthews <josh@joshmatthews.net>2014-09-13 11:22:29 -0400
commit8748818b7e11e910a95d34eb9ed5865c5ea101cf (patch)
tree3c1cb1770bfa4b3e822fc7e4b4673edcccd421b8 /components/script/html/hubbub_html_parser.rs
parent5a90f18b7ee9a73511920acfb1e8b04c8c36372e (diff)
downloadservo-8748818b7e11e910a95d34eb9ed5865c5ea101cf.tar.gz
servo-8748818b7e11e910a95d34eb9ed5865c5ea101cf.zip
Don't fail converting invalid UTF8 when fetching JS source. Fixes #3302.
Diffstat (limited to 'components/script/html/hubbub_html_parser.rs')
-rw-r--r--components/script/html/hubbub_html_parser.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/components/script/html/hubbub_html_parser.rs b/components/script/html/hubbub_html_parser.rs
index 6862ef4a492..89d817b9380 100644
--- a/components/script/html/hubbub_html_parser.rs
+++ b/components/script/html/hubbub_html_parser.rs
@@ -20,6 +20,9 @@ use dom::types::*;
use html::cssparse::{StylesheetProvenance, UrlProvenance, spawn_css_parser};
use page::Page;
+use encoding::all::UTF_8;
+use encoding::types::{Encoding, DecodeReplace};
+
use hubbub::hubbub;
use hubbub::hubbub::{NullNs, HtmlNs, MathMlNs, SvgNs, XLinkNs, XmlNs, XmlNsNs};
use servo_net::resource_task::{Load, LoadData, Payload, Done, ResourceTask, load_whole_resource};
@@ -142,8 +145,9 @@ fn js_script_listener(to_parent: Sender<HtmlDiscoveryMessage>,
error!("error loading script {:s}", url.serialize());
}
Ok((metadata, bytes)) => {
+ let decoded = UTF_8.decode(bytes.as_slice(), DecodeReplace).unwrap();
result_vec.push(JSFile {
- data: String::from_utf8(bytes).unwrap().to_string(),
+ data: decoded.to_string(),
url: metadata.final_url,
});
}