mirror of
https://github.com/servo/servo.git
synced 2025-07-22 06:43:40 +01:00
Update hyper to 0.12
This commit is contained in:
parent
95bfaa0a77
commit
024b40b39d
122 changed files with 3835 additions and 3448 deletions
|
@ -2,9 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use hyper::mime::TopLevel;
|
||||
use mime::{self, Mime};
|
||||
use net_traits::LoadContext;
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
pub struct MimeClassifier {
|
||||
image_classifier: GroupedClassifier,
|
||||
|
@ -49,34 +48,28 @@ pub enum NoSniffFlag {
|
|||
Off
|
||||
}
|
||||
|
||||
pub type MimeType = (TopLevel, String);
|
||||
|
||||
|
||||
impl MimeClassifier {
|
||||
//Performs MIME Type Sniffing Algorithm (sections 7 and 8)
|
||||
pub fn classify(&self,
|
||||
pub fn classify<'a>(&'a self,
|
||||
context: LoadContext,
|
||||
no_sniff_flag: NoSniffFlag,
|
||||
apache_bug_flag: ApacheBugFlag,
|
||||
supplied_type: &Option<MimeType>,
|
||||
data: &[u8]) -> MimeType {
|
||||
let supplied_type_or_octet_stream = supplied_type.clone()
|
||||
.unwrap_or((TopLevel::Application,
|
||||
"octet-stream".to_owned()));
|
||||
supplied_type: &Option<Mime>,
|
||||
data: &'a [u8]) -> Mime {
|
||||
let supplied_type_or_octet_stream = supplied_type.clone().unwrap_or(mime::APPLICATION_OCTET_STREAM);
|
||||
match context {
|
||||
LoadContext::Browsing => match *supplied_type {
|
||||
None => self.sniff_unknown_type(no_sniff_flag, data),
|
||||
Some(ref supplied_type) => {
|
||||
let &(ref media_type, ref media_subtype) = supplied_type;
|
||||
if MimeClassifier::is_explicit_unknown(media_type, media_subtype) {
|
||||
if MimeClassifier::is_explicit_unknown(supplied_type) {
|
||||
self.sniff_unknown_type(no_sniff_flag, data)
|
||||
} else {
|
||||
match no_sniff_flag {
|
||||
NoSniffFlag::On => supplied_type.clone(),
|
||||
NoSniffFlag::Off => match apache_bug_flag {
|
||||
ApacheBugFlag::On => self.sniff_text_or_data(data),
|
||||
ApacheBugFlag::Off => match MimeClassifier::get_media_type(media_type,
|
||||
media_subtype) {
|
||||
ApacheBugFlag::Off => match MimeClassifier::get_media_type(supplied_type) {
|
||||
Some(MediaType::Html) => self.feeds_classifier.classify(data),
|
||||
Some(MediaType::Image) => self.image_classifier.classify(data),
|
||||
Some(MediaType::AudioVideo) => self.audio_video_classifier.classify(data),
|
||||
|
@ -107,7 +100,7 @@ impl MimeClassifier {
|
|||
// This section was *not* finalized in the specs at the time
|
||||
// of this implementation.
|
||||
match *supplied_type {
|
||||
None => (TopLevel::Application, "octet-stream".to_owned()),
|
||||
None => mime::APPLICATION_OCTET_STREAM,
|
||||
_ => supplied_type_or_octet_stream,
|
||||
}
|
||||
},
|
||||
|
@ -117,7 +110,7 @@ impl MimeClassifier {
|
|||
// This section was *not* finalized in the specs at the time
|
||||
// of this implementation.
|
||||
match *supplied_type {
|
||||
None => (TopLevel::Text, "css".to_owned()),
|
||||
None => mime::TEXT_CSS,
|
||||
_ => supplied_type_or_octet_stream,
|
||||
}
|
||||
},
|
||||
|
@ -127,7 +120,7 @@ impl MimeClassifier {
|
|||
// This section was *not* finalized in the specs at the time
|
||||
// of this implementation.
|
||||
match *supplied_type {
|
||||
None => (TopLevel::Text, "javascript".to_owned()),
|
||||
None => mime::TEXT_JAVASCRIPT,
|
||||
_ => supplied_type_or_octet_stream,
|
||||
}
|
||||
},
|
||||
|
@ -143,14 +136,14 @@ impl MimeClassifier {
|
|||
//
|
||||
// This section was *not* finalized in the specs at the time
|
||||
// of this implementation.
|
||||
(TopLevel::Text, "vtt".to_owned())
|
||||
"text/vtt".parse().unwrap()
|
||||
},
|
||||
LoadContext::CacheManifest => {
|
||||
// 8.9 Sniffing in a cache manifest context
|
||||
//
|
||||
// This section was *not* finalized in the specs at the time
|
||||
// of this implementation.
|
||||
(TopLevel::Text, "cache-manifest".to_owned())
|
||||
"text/cache-manifest".parse().unwrap()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +174,7 @@ impl MimeClassifier {
|
|||
}
|
||||
|
||||
//some sort of iterator over the classifiers might be better?
|
||||
fn sniff_unknown_type(&self, no_sniff_flag: NoSniffFlag, data: &[u8]) -> MimeType {
|
||||
fn sniff_unknown_type(&self, no_sniff_flag: NoSniffFlag, data: &[u8]) -> Mime {
|
||||
let should_sniff_scriptable = no_sniff_flag == NoSniffFlag::Off;
|
||||
let sniffed = if should_sniff_scriptable {
|
||||
self.scriptable_classifier.classify(data)
|
||||
|
@ -197,72 +190,60 @@ impl MimeClassifier {
|
|||
.expect("BinaryOrPlaintextClassifier always succeeds")
|
||||
}
|
||||
|
||||
fn sniff_text_or_data(&self, data: &[u8]) -> MimeType {
|
||||
fn sniff_text_or_data<'a>(&'a self, data: &'a [u8]) -> Mime {
|
||||
self.binary_or_plaintext.classify(data).expect("BinaryOrPlaintextClassifier always succeeds")
|
||||
}
|
||||
|
||||
fn is_xml(tp: &TopLevel, sub_tp: &str) -> bool {
|
||||
sub_tp.ends_with("+xml") ||
|
||||
match (tp, sub_tp) {
|
||||
(&TopLevel::Application, "xml") | (&TopLevel::Text, "xml") => true,
|
||||
_ => false
|
||||
}
|
||||
fn is_xml(mt: &Mime) -> bool {
|
||||
mt.suffix() == Some(mime::XML) ||
|
||||
(mt.type_() == mime::APPLICATION && mt.subtype() == mime::XML) ||
|
||||
(mt.type_() == mime::TEXT && mt.subtype() == mime::XML)
|
||||
}
|
||||
|
||||
fn is_html(tp: &TopLevel, sub_tp: &str) -> bool {
|
||||
*tp == TopLevel::Text && sub_tp == "html"
|
||||
fn is_html(mt: &Mime) -> bool {
|
||||
mt.type_() == mime::TEXT && mt.subtype() == mime::HTML
|
||||
}
|
||||
|
||||
fn is_image(tp: &TopLevel) -> bool {
|
||||
*tp == TopLevel::Image
|
||||
fn is_image(mt: &Mime) -> bool {
|
||||
mt.type_() == mime::IMAGE
|
||||
}
|
||||
|
||||
fn is_audio_video(tp: &TopLevel, sub_tp: &str) -> bool {
|
||||
*tp == TopLevel::Audio ||
|
||||
*tp == TopLevel::Video ||
|
||||
(*tp == TopLevel::Application && sub_tp == "ogg")
|
||||
fn is_audio_video(mt: &Mime) -> bool {
|
||||
mt.type_() == mime::AUDIO ||
|
||||
mt.type_() == mime::VIDEO ||
|
||||
mt.type_() == mime::APPLICATION && mt.subtype() == mime::OGG
|
||||
}
|
||||
|
||||
fn is_explicit_unknown(tp: &TopLevel, sub_tp: &str) -> bool {
|
||||
if let TopLevel::Ext(ref e) = *tp {
|
||||
return e == "unknown" && sub_tp == "unknown";
|
||||
}
|
||||
match (tp, sub_tp) {
|
||||
(&TopLevel::Application, "unknown") |
|
||||
(&TopLevel::Star, "*") => true,
|
||||
_ => false
|
||||
}
|
||||
fn is_explicit_unknown(mt: &Mime) -> bool {
|
||||
mt.type_().as_str() == "unknown" && mt.subtype().as_str() == "unknown" ||
|
||||
mt.type_() == mime::APPLICATION && mt.subtype().as_str() == "unknown" ||
|
||||
mt.type_() == mime::STAR && mt.subtype() == mime::STAR
|
||||
}
|
||||
|
||||
fn get_media_type(media_type: &TopLevel,
|
||||
media_subtype: &str) -> Option<MediaType> {
|
||||
if MimeClassifier::is_xml(media_type, media_subtype) {
|
||||
fn get_media_type(mime: &Mime) -> Option<MediaType> {
|
||||
if MimeClassifier::is_xml(&mime) {
|
||||
Some(MediaType::Xml)
|
||||
} else if MimeClassifier::is_html(media_type, media_subtype) {
|
||||
} else if MimeClassifier::is_html(&mime) {
|
||||
Some(MediaType::Html)
|
||||
} else if MimeClassifier::is_image(media_type) {
|
||||
} else if MimeClassifier::is_image(&mime) {
|
||||
Some(MediaType::Image)
|
||||
} else if MimeClassifier::is_audio_video(media_type, media_subtype) {
|
||||
} else if MimeClassifier::is_audio_video(&mime) {
|
||||
Some(MediaType::AudioVideo)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe_get_media_type(supplied_type: &Option<MimeType>) -> Option<MediaType> {
|
||||
supplied_type.as_ref().and_then(|&(ref media_type, ref media_subtype)| {
|
||||
MimeClassifier::get_media_type(media_type, media_subtype)
|
||||
fn maybe_get_media_type(supplied_type: &Option<Mime>) -> Option<MediaType> {
|
||||
supplied_type.as_ref().and_then(|ref mime| {
|
||||
MimeClassifier::get_media_type(mime)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_string_option(tup: Option<(TopLevel, &'static str)>) -> Option<MimeType> {
|
||||
tup.map(|(a, b)| (a.to_owned(), b.to_owned()))
|
||||
}
|
||||
|
||||
//Interface used for composite types
|
||||
trait MIMEChecker {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType>;
|
||||
fn classify(&self, data: &[u8]) -> Option<Mime>;
|
||||
/// Validate the MIME checker configuration
|
||||
fn validate(&self) -> Result<(), String>;
|
||||
}
|
||||
|
@ -303,7 +284,7 @@ struct ByteMatcher {
|
|||
pattern: &'static [u8],
|
||||
mask: &'static [u8],
|
||||
leading_ignore: &'static [u8],
|
||||
content_type: (TopLevel, &'static str)
|
||||
content_type: Mime,
|
||||
}
|
||||
|
||||
impl ByteMatcher {
|
||||
|
@ -328,31 +309,31 @@ impl ByteMatcher {
|
|||
}
|
||||
|
||||
impl MIMEChecker for ByteMatcher {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
fn classify(&self, data: &[u8]) -> Option<Mime> {
|
||||
self.matches(data).map(|_| {
|
||||
(self.content_type.0.to_owned(), self.content_type.1.to_owned())
|
||||
self.content_type.clone()
|
||||
})
|
||||
}
|
||||
|
||||
fn validate(&self) -> Result<(), String> {
|
||||
if self.pattern.len() == 0 {
|
||||
return Err(format!(
|
||||
"Zero length pattern for {}/{}",
|
||||
self.content_type.0, self.content_type.1
|
||||
"Zero length pattern for {:?}",
|
||||
self.content_type
|
||||
))
|
||||
}
|
||||
if self.pattern.len() != self.mask.len() {
|
||||
return Err(format!(
|
||||
"Unequal pattern and mask length for {}/{}",
|
||||
self.content_type.0, self.content_type.1
|
||||
"Unequal pattern and mask length for {:?}",
|
||||
self.content_type
|
||||
))
|
||||
}
|
||||
if self.pattern.iter().zip(self.mask.iter()).any(
|
||||
|(&pattern, &mask)| pattern & mask != pattern
|
||||
) {
|
||||
return Err(format!(
|
||||
"Pattern not pre-masked for {}/{}",
|
||||
self.content_type.0, self.content_type.1
|
||||
"Pattern not pre-masked for {:?}",
|
||||
self.content_type
|
||||
))
|
||||
}
|
||||
Ok(())
|
||||
|
@ -364,11 +345,10 @@ struct TagTerminatedByteMatcher {
|
|||
}
|
||||
|
||||
impl MIMEChecker for TagTerminatedByteMatcher {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
fn classify(&self, data: &[u8]) -> Option<Mime> {
|
||||
self.matcher.matches(data).and_then(|j|
|
||||
if j < data.len() && (data[j] == b' ' || data[j] == b'>') {
|
||||
Some((self.matcher.content_type.0.to_owned(),
|
||||
self.matcher.content_type.1.to_owned()))
|
||||
Some(self.matcher.content_type.clone())
|
||||
} else {
|
||||
None
|
||||
})
|
||||
|
@ -405,9 +385,9 @@ impl Mp4Matcher {
|
|||
|
||||
}
|
||||
impl MIMEChecker for Mp4Matcher {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
fn classify(&self, data: &[u8]) -> Option<Mime> {
|
||||
if self.matches(data) {
|
||||
Some((TopLevel::Video, "mp4".to_owned()))
|
||||
Some("video/mp4".parse().unwrap())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -421,25 +401,25 @@ impl MIMEChecker for Mp4Matcher {
|
|||
struct BinaryOrPlaintextClassifier;
|
||||
|
||||
impl BinaryOrPlaintextClassifier {
|
||||
fn classify_impl(&self, data: &[u8]) -> (TopLevel, &'static str) {
|
||||
fn classify_impl(&self, data: &[u8]) -> Mime {
|
||||
if data.starts_with(&[0xFFu8, 0xFEu8]) ||
|
||||
data.starts_with(&[0xFEu8, 0xFFu8]) ||
|
||||
data.starts_with(&[0xEFu8, 0xBBu8, 0xBFu8])
|
||||
{
|
||||
(TopLevel::Text, "plain")
|
||||
mime::TEXT_PLAIN
|
||||
} else if data.iter().any(|&x| x <= 0x08u8 ||
|
||||
x == 0x0Bu8 ||
|
||||
(x >= 0x0Eu8 && x <= 0x1Au8) ||
|
||||
(x >= 0x1Cu8 && x <= 0x1Fu8)) {
|
||||
(TopLevel::Application, "octet-stream")
|
||||
mime::APPLICATION_OCTET_STREAM
|
||||
} else {
|
||||
(TopLevel::Text, "plain")
|
||||
mime::TEXT_PLAIN
|
||||
}
|
||||
}
|
||||
}
|
||||
impl MIMEChecker for BinaryOrPlaintextClassifier {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
as_string_option(Some(self.classify_impl(data)))
|
||||
fn classify(&self, data: &[u8]) -> Option<Mime> {
|
||||
Some(self.classify_impl(data))
|
||||
}
|
||||
|
||||
fn validate(&self) -> Result<(), String> {
|
||||
|
@ -538,7 +518,7 @@ impl GroupedClassifier {
|
|||
}
|
||||
}
|
||||
impl MIMEChecker for GroupedClassifier {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
fn classify(&self, data: &[u8]) -> Option<Mime> {
|
||||
self.byte_matchers
|
||||
.iter()
|
||||
.filter_map(|matcher| matcher.classify(data))
|
||||
|
@ -591,7 +571,7 @@ where T: Iterator<Item=&'a u8> + Clone {
|
|||
struct FeedsClassifier;
|
||||
impl FeedsClassifier {
|
||||
// Implements sniffing for mislabeled feeds (https://mimesniff.spec.whatwg.org/#sniffing-a-mislabeled-feed)
|
||||
fn classify_impl(&self, data: &[u8]) -> Option<(TopLevel, &'static str)> {
|
||||
fn classify_impl(&self, data: &[u8]) -> Option<Mime> {
|
||||
// Step 4: can not be feed unless length is > 3
|
||||
if data.len() < 3 {
|
||||
return None;
|
||||
|
@ -622,11 +602,11 @@ impl FeedsClassifier {
|
|||
|
||||
// Step 5.2.5
|
||||
if matcher.matches(b"rss") {
|
||||
return Some((TopLevel::Application, "rss+xml"));
|
||||
return Some("application/rss+xml".parse().unwrap());
|
||||
}
|
||||
// Step 5.2.6
|
||||
if matcher.matches(b"feed") {
|
||||
return Some((TopLevel::Application, "atom+xml"));
|
||||
return Some("application/atom+xml".parse().unwrap());
|
||||
}
|
||||
// Step 5.2.7
|
||||
if matcher.matches(b"rdf:RDF") {
|
||||
|
@ -637,7 +617,7 @@ impl FeedsClassifier {
|
|||
.chain(|| eats_until(&mut matcher,
|
||||
b"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
||||
b"http://purl.org/rss/1.0/")) {
|
||||
Match::StartAndEnd => return Some((TopLevel::Application, "rss+xml")),
|
||||
Match::StartAndEnd => return Some("application/rss+xml".parse().unwrap()),
|
||||
Match::DidNotMatch => {},
|
||||
Match::Start => return None
|
||||
}
|
||||
|
@ -649,8 +629,8 @@ impl FeedsClassifier {
|
|||
}
|
||||
|
||||
impl MIMEChecker for FeedsClassifier {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
as_string_option(self.classify_impl(data))
|
||||
fn classify(&self, data: &[u8]) -> Option<Mime> {
|
||||
self.classify_impl(data)
|
||||
}
|
||||
|
||||
fn validate(&self) -> Result<(), String> {
|
||||
|
@ -666,7 +646,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\x00\x00\x01\x00",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "x-icon"),
|
||||
content_type: "image/x-icon".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -675,7 +655,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\x00\x00\x02\x00",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "x-icon"),
|
||||
content_type: "image/x-icon".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -684,7 +664,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"BM",
|
||||
mask: b"\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "bmp"),
|
||||
content_type: mime::IMAGE_BMP,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -693,7 +673,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"GIF89a",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "gif"),
|
||||
content_type: mime::IMAGE_GIF,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -702,7 +682,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"GIF87a",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "gif"),
|
||||
content_type: mime::IMAGE_GIF,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +691,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"RIFF\x00\x00\x00\x00WEBPVP",
|
||||
mask: b"\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "webp"),
|
||||
content_type: "image/webp".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -721,7 +701,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\x89PNG\r\n\x1A\n",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "png"),
|
||||
content_type: mime::IMAGE_PNG,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -730,7 +710,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\xFF\xD8\xFF",
|
||||
mask: b"\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Image, "jpeg"),
|
||||
content_type: mime::IMAGE_JPEG,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -739,7 +719,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\x1A\x45\xDF\xA3",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Video, "webm"),
|
||||
content_type: "video/webm".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -748,7 +728,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b".snd",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Audio, "basic"),
|
||||
content_type: "audio/basic".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -757,7 +737,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"FORM\x00\x00\x00\x00AIFF",
|
||||
mask: b"\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Audio, "aiff"),
|
||||
content_type: "audio/aiff".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -766,7 +746,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"ID3",
|
||||
mask: b"\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Audio, "mpeg"),
|
||||
content_type: "audio/mpeg".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -775,7 +755,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"OggS\x00",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "ogg"),
|
||||
content_type: "application/ogg".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -785,7 +765,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"MThd\x00\x00\x00\x06",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Audio, "midi"),
|
||||
content_type: "audio/midi".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -794,7 +774,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"RIFF\x00\x00\x00\x00AVI ",
|
||||
mask: b"\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Video, "avi"),
|
||||
content_type: "video/avi".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -803,7 +783,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"RIFF\x00\x00\x00\x00WAVE",
|
||||
mask: b"\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Audio, "wave"),
|
||||
content_type: "audio/wave".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -813,7 +793,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<!DOCTYPE HTML",
|
||||
mask: b"\xFF\xFF\xDF\xDF\xDF\xDF\xDF\xDF\xDF\xFF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -825,7 +805,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<HTML",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -837,7 +817,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<HEAD",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -849,7 +829,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<SCRIPT",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -861,7 +841,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<IFRAME",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -873,7 +853,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<H1",
|
||||
mask: b"\xFF\xDF\xFF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -885,7 +865,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<DIV",
|
||||
mask: b"\xFF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -897,7 +877,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<FONT",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -909,7 +889,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<TABLE",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -921,7 +901,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<A",
|
||||
mask: b"\xFF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -933,7 +913,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<STYLE",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -945,7 +925,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<TITLE",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -957,7 +937,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<B",
|
||||
mask: b"\xFF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -969,7 +949,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<BODY",
|
||||
mask: b"\xFF\xDF\xDF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -981,7 +961,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<BR",
|
||||
mask: b"\xFF\xDF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -993,7 +973,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<P",
|
||||
mask: b"\xFF\xDF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -1005,7 +985,7 @@ impl ByteMatcher {
|
|||
matcher: ByteMatcher {
|
||||
pattern: b"<!--",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Text, "html"),
|
||||
content_type: mime::TEXT_HTML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -1016,7 +996,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"<?xml",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Text, "xml"),
|
||||
content_type: mime::TEXT_XML,
|
||||
leading_ignore: b"\t\n\x0C\r "
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1005,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"%PDF-",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "pdf"),
|
||||
content_type: mime::APPLICATION_PDF,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1038,7 +1018,7 @@ impl ByteMatcher {
|
|||
mask: b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||
\x00\x00\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "vnd.ms-fontobject"),
|
||||
content_type: "application/vnd.ms-fontobject".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1047,7 +1027,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\x00\x01\x00\x00",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "font-sfnt"),
|
||||
content_type: "application/font-sfnt".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1056,7 +1036,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"OTTO",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "font-sfnt"),
|
||||
content_type: "application/font-sfnt".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1065,7 +1045,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"ttcf",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "font-sfnt"),
|
||||
content_type: "application/font-sfnt".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1074,7 +1054,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"wOFF",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "font-woff"),
|
||||
content_type: "application/font-woff".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1083,7 +1063,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\x1F\x8B\x08",
|
||||
mask: b"\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "x-gzip"),
|
||||
content_type: "application/x-gzip".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1092,7 +1072,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"PK\x03\x04",
|
||||
mask: b"\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "zip"),
|
||||
content_type: "application/zip".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1101,7 +1081,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"Rar \x1A\x07\x00",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "x-rar-compressed"),
|
||||
content_type: "application/x-rar-compressed".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1110,7 +1090,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"%!PS-Adobe-",
|
||||
mask: b"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF",
|
||||
content_type: (TopLevel::Application, "postscript"),
|
||||
content_type: "application/postscript".parse().unwrap(),
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1119,7 +1099,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\xFE\xFF\x00\x00",
|
||||
mask: b"\xFF\xFF\x00\x00",
|
||||
content_type: (TopLevel::Text, "plain"),
|
||||
content_type: mime::TEXT_PLAIN,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1128,7 +1108,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\xFF\xFE\x00\x00",
|
||||
mask: b"\xFF\xFF\x00\x00",
|
||||
content_type: (TopLevel::Text, "plain"),
|
||||
content_type: mime::TEXT_PLAIN,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
@ -1137,7 +1117,7 @@ impl ByteMatcher {
|
|||
ByteMatcher {
|
||||
pattern: b"\xEF\xBB\xBF\x00",
|
||||
mask: b"\xFF\xFF\xFF\x00",
|
||||
content_type: (TopLevel::Text, "plain"),
|
||||
content_type: mime::TEXT_PLAIN,
|
||||
leading_ignore: &[]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue