make mediatype default to text/plain in data URIs

change `data:charset=` to `data:;charset=` and set US-ASCII as default encoding

style change
This commit is contained in:
minimus 2015-10-02 15:01:55 -04:00
parent e40dd3843f
commit d4ebec6496
2 changed files with 33 additions and 6 deletions

View file

@ -47,7 +47,11 @@ fn empty_invalid() {
#[test]
fn plain() {
assert_parse("data:,hello%20world", None, None, Some(b"hello world".iter().map(|&x| x).collect()));
assert_parse(
"data:,hello%20world",
Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain,
vec!((Attr::Charset, Value::Ext("us-ascii".to_owned())))))),
Some("US-ASCII".to_owned()), Some(b"hello world".iter().map(|&x| x).collect()));
}
#[test]
@ -68,9 +72,24 @@ fn plain_charset() {
Some("latin1".to_string()), Some(b"hello".iter().map(|&x| x).collect()));
}
#[test]
fn plain_only_charset() {
assert_parse(
"data:;charset=utf-8,hello",
Some(ContentType(Mime(TopLevel::Text,
SubLevel::Plain,
vec!((Attr::Charset, Value::Utf8))))),
Some("utf-8".to_string()), Some(b"hello".iter().map(|&x| x).collect()));
}
#[test]
fn base64() {
assert_parse("data:;base64,C62+7w==", None, None, Some(vec!(0x0B, 0xAD, 0xBE, 0xEF)));
assert_parse(
"data:;base64,C62+7w==",
Some(ContentType(Mime(TopLevel::Text,
SubLevel::Plain,
vec!((Attr::Charset, Value::Ext("us-ascii".to_owned())))))),
Some("US-ASCII".to_owned()), Some(vec!(0x0B, 0xAD, 0xBE, 0xEF)));
}
#[test]