mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #10640 - frewsxcv:apache-flag, r=KiChjang
Cleanup code regarding mimesniff 'apache bug'. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10640) <!-- Reviewable:end -->
This commit is contained in:
commit
6edcad206d
2 changed files with 16 additions and 16 deletions
|
@ -83,11 +83,8 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
|
|||
let mut check_for_apache_bug = ApacheBugFlag::OFF;
|
||||
|
||||
if let Some(ref headers) = metadata.headers {
|
||||
if let Some(ref raw_content_type) = headers.get_raw("content-type") {
|
||||
if raw_content_type.len() > 0 {
|
||||
let last_raw_content_type = &raw_content_type[raw_content_type.len() - 1];
|
||||
check_for_apache_bug = apache_bug_predicate(last_raw_content_type)
|
||||
}
|
||||
if let Some(ref content_type) = headers.get_raw("content-type").and_then(|c| c.last()) {
|
||||
check_for_apache_bug = ApacheBugFlag::from_content_type(content_type)
|
||||
}
|
||||
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") {
|
||||
|
@ -113,17 +110,6 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
|
|||
start_sending_opt(start_chan, metadata)
|
||||
}
|
||||
|
||||
fn apache_bug_predicate(last_raw_content_type: &[u8]) -> ApacheBugFlag {
|
||||
if last_raw_content_type == b"text/plain"
|
||||
|| 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" {
|
||||
ApacheBugFlag::ON
|
||||
} else {
|
||||
ApacheBugFlag::OFF
|
||||
}
|
||||
}
|
||||
|
||||
/// For use by loaders in responding to a Load message.
|
||||
fn start_sending_opt(start_chan: LoadConsumer, metadata: Metadata) -> Result<ProgressSender, ()> {
|
||||
match start_chan {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue