mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add check that ByteMatcher pattern has the mask applied
This commit is contained in:
parent
480cb385fc
commit
6ea656c6c5
1 changed files with 9 additions and 1 deletions
|
@ -299,7 +299,7 @@ impl ByteMatcher {
|
||||||
.and_then(|start|
|
.and_then(|start|
|
||||||
if data[start..].iter()
|
if data[start..].iter()
|
||||||
.zip(self.pattern.iter()).zip(self.mask.iter())
|
.zip(self.pattern.iter()).zip(self.mask.iter())
|
||||||
.all(|((&data, &pattern), &mask)| (data & mask) == (pattern & mask)) {
|
.all(|((&data, &pattern), &mask)| (data & mask) == pattern) {
|
||||||
Some(start + self.pattern.len())
|
Some(start + self.pattern.len())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -328,6 +328,14 @@ impl MIMEChecker for ByteMatcher {
|
||||||
self.content_type.0, self.content_type.1
|
self.content_type.0, self.content_type.1
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
))
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue