mirror of
https://github.com/servo/servo.git
synced 2025-07-03 13:33:39 +01:00
Auto merge of #13652 - frewsxcv:variant-naming, r=jdm
Fix capitalization for enum variants. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13652) <!-- Reviewable:end -->
This commit is contained in:
commit
3768ea2cc7
3 changed files with 30 additions and 30 deletions
|
@ -24,8 +24,8 @@ pub enum MediaType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ApacheBugFlag {
|
pub enum ApacheBugFlag {
|
||||||
ON,
|
On,
|
||||||
OFF
|
Off
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ApacheBugFlag {
|
impl ApacheBugFlag {
|
||||||
|
@ -35,17 +35,17 @@ impl ApacheBugFlag {
|
||||||
|| last_raw_content_type == b"text/plain; charset=ISO-8859-1"
|
|| last_raw_content_type == b"text/plain; charset=ISO-8859-1"
|
||||||
|| last_raw_content_type == b"text/plain; charset=iso-8859-1"
|
|| last_raw_content_type == b"text/plain; charset=iso-8859-1"
|
||||||
|| last_raw_content_type == b"text/plain; charset=UTF-8" {
|
|| last_raw_content_type == b"text/plain; charset=UTF-8" {
|
||||||
ApacheBugFlag::ON
|
ApacheBugFlag::On
|
||||||
} else {
|
} else {
|
||||||
ApacheBugFlag::OFF
|
ApacheBugFlag::Off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum NoSniffFlag {
|
pub enum NoSniffFlag {
|
||||||
ON,
|
On,
|
||||||
OFF
|
Off
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type MimeType = (String, String);
|
pub type MimeType = (String, String);
|
||||||
|
@ -70,10 +70,10 @@ impl MimeClassifier {
|
||||||
self.sniff_unknown_type(no_sniff_flag, data)
|
self.sniff_unknown_type(no_sniff_flag, data)
|
||||||
} else {
|
} else {
|
||||||
match no_sniff_flag {
|
match no_sniff_flag {
|
||||||
NoSniffFlag::ON => supplied_type.clone(),
|
NoSniffFlag::On => supplied_type.clone(),
|
||||||
NoSniffFlag::OFF => match apache_bug_flag {
|
NoSniffFlag::Off => match apache_bug_flag {
|
||||||
ApacheBugFlag::ON => self.sniff_text_or_data(data),
|
ApacheBugFlag::On => self.sniff_text_or_data(data),
|
||||||
ApacheBugFlag::OFF => match MimeClassifier::get_media_type(media_type,
|
ApacheBugFlag::Off => match MimeClassifier::get_media_type(media_type,
|
||||||
media_subtype) {
|
media_subtype) {
|
||||||
Some(MediaType::Html) => self.feeds_classifier.classify(data),
|
Some(MediaType::Html) => self.feeds_classifier.classify(data),
|
||||||
Some(MediaType::Image) => self.image_classifier.classify(data),
|
Some(MediaType::Image) => self.image_classifier.classify(data),
|
||||||
|
@ -180,7 +180,7 @@ impl MimeClassifier {
|
||||||
|
|
||||||
//some sort of iterator over the classifiers might be better?
|
//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]) -> MimeType {
|
||||||
let should_sniff_scriptable = no_sniff_flag == NoSniffFlag::OFF;
|
let should_sniff_scriptable = no_sniff_flag == NoSniffFlag::Off;
|
||||||
let sniffed = if should_sniff_scriptable {
|
let sniffed = if should_sniff_scriptable {
|
||||||
self.scriptable_classifier.classify(data)
|
self.scriptable_classifier.classify(data)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -101,8 +101,8 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
|
||||||
-> Result<ProgressSender, ()> {
|
-> Result<ProgressSender, ()> {
|
||||||
if PREFS.get("network.mime.sniff").as_boolean().unwrap_or(false) {
|
if PREFS.get("network.mime.sniff").as_boolean().unwrap_or(false) {
|
||||||
// TODO: should be calculated in the resource loader, from pull requeset #4094
|
// TODO: should be calculated in the resource loader, from pull requeset #4094
|
||||||
let mut no_sniff = NoSniffFlag::OFF;
|
let mut no_sniff = NoSniffFlag::Off;
|
||||||
let mut check_for_apache_bug = ApacheBugFlag::OFF;
|
let mut check_for_apache_bug = ApacheBugFlag::Off;
|
||||||
|
|
||||||
if let Some(ref headers) = metadata.headers {
|
if let Some(ref headers) = metadata.headers {
|
||||||
if let Some(ref content_type) = headers.get_raw("content-type").and_then(|c| c.last()) {
|
if let Some(ref content_type) = headers.get_raw("content-type").and_then(|c| c.last()) {
|
||||||
|
@ -110,7 +110,7 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
|
||||||
}
|
}
|
||||||
if let Some(ref raw_content_type_options) = headers.get_raw("X-content-type-options") {
|
if let Some(ref raw_content_type_options) = headers.get_raw("X-content-type-options") {
|
||||||
if raw_content_type_options.iter().any(|ref opt| *opt == b"nosniff") {
|
if raw_content_type_options.iter().any(|ref opt| *opt == b"nosniff") {
|
||||||
no_sniff = NoSniffFlag::ON
|
no_sniff = NoSniffFlag::On
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,8 @@ fn test_sniff_full(filename_orig: &path::Path, type_string: &str, subtype_string
|
||||||
type_string,
|
type_string,
|
||||||
subtype_string,
|
subtype_string,
|
||||||
supplied_type,
|
supplied_type,
|
||||||
NoSniffFlag::OFF,
|
NoSniffFlag::Off,
|
||||||
ApacheBugFlag::OFF)
|
ApacheBugFlag::Off)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -494,8 +494,8 @@ fn test_sniff_atom_feed_with_no_sniff_flag_on() {
|
||||||
"text",
|
"text",
|
||||||
"html",
|
"html",
|
||||||
Some(("text", "html")),
|
Some(("text", "html")),
|
||||||
NoSniffFlag::ON,
|
NoSniffFlag::On,
|
||||||
ApacheBugFlag::OFF);
|
ApacheBugFlag::Off);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -504,8 +504,8 @@ fn test_sniff_with_no_sniff_flag_on_and_apache_flag_on() {
|
||||||
"text",
|
"text",
|
||||||
"html",
|
"html",
|
||||||
Some(("text", "html")),
|
Some(("text", "html")),
|
||||||
NoSniffFlag::ON,
|
NoSniffFlag::On,
|
||||||
ApacheBugFlag::ON);
|
ApacheBugFlag::On);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -514,8 +514,8 @@ fn test_sniff_utf_8_bom_with_apache_flag_on() {
|
||||||
"text",
|
"text",
|
||||||
"plain",
|
"plain",
|
||||||
Some(("dummy", "text")),
|
Some(("dummy", "text")),
|
||||||
NoSniffFlag::OFF,
|
NoSniffFlag::Off,
|
||||||
ApacheBugFlag::ON);
|
ApacheBugFlag::On);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -524,8 +524,8 @@ fn test_sniff_utf_16be_bom_with_apache_flag_on() {
|
||||||
"text",
|
"text",
|
||||||
"plain",
|
"plain",
|
||||||
Some(("dummy", "text")),
|
Some(("dummy", "text")),
|
||||||
NoSniffFlag::OFF,
|
NoSniffFlag::Off,
|
||||||
ApacheBugFlag::ON);
|
ApacheBugFlag::On);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -534,8 +534,8 @@ fn test_sniff_utf_16le_bom_with_apache_flag_on() {
|
||||||
"text",
|
"text",
|
||||||
"plain",
|
"plain",
|
||||||
Some(("dummy", "text")),
|
Some(("dummy", "text")),
|
||||||
NoSniffFlag::OFF,
|
NoSniffFlag::Off,
|
||||||
ApacheBugFlag::ON);
|
ApacheBugFlag::On);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -544,8 +544,8 @@ fn test_sniff_octet_stream_apache_flag_on() {
|
||||||
"application",
|
"application",
|
||||||
"octet-stream",
|
"octet-stream",
|
||||||
Some(("dummy", "binary")),
|
Some(("dummy", "binary")),
|
||||||
NoSniffFlag::OFF,
|
NoSniffFlag::Off,
|
||||||
ApacheBugFlag::ON);
|
ApacheBugFlag::On);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -554,6 +554,6 @@ fn test_sniff_mp4_video_apache_flag_on() {
|
||||||
"application",
|
"application",
|
||||||
"octet-stream",
|
"octet-stream",
|
||||||
Some(("video", "mp4")),
|
Some(("video", "mp4")),
|
||||||
NoSniffFlag::OFF,
|
NoSniffFlag::Off,
|
||||||
ApacheBugFlag::ON);
|
ApacheBugFlag::On);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue