mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Shift checking for IP address host for HSTS entry to constructor
servo/servo#6105
This commit is contained in:
parent
cb9b0c2a7a
commit
8d39fb6dcf
2 changed files with 41 additions and 41 deletions
|
@ -198,12 +198,16 @@ pub struct HSTSEntry {
|
|||
}
|
||||
|
||||
impl HSTSEntry {
|
||||
pub fn new(host: String, include_subdomains: bool, max_age: Option<u64>) -> HSTSEntry {
|
||||
HSTSEntry {
|
||||
host: host,
|
||||
include_subdomains: include_subdomains,
|
||||
max_age: max_age,
|
||||
timestamp: Some(time::get_time().sec as u64)
|
||||
pub fn new(host: String, include_subdomains: bool, max_age: Option<u64>) -> Option<HSTSEntry> {
|
||||
if IPV4_REGEX.is_match(&host) || IPV6_REGEX.is_match(&host) {
|
||||
None
|
||||
} else {
|
||||
Some(HSTSEntry {
|
||||
host: host,
|
||||
include_subdomains: include_subdomains,
|
||||
max_age: max_age,
|
||||
timestamp: Some(time::get_time().sec as u64)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,10 +261,6 @@ impl HSTSList {
|
|||
}
|
||||
|
||||
pub fn push(&mut self, entry: HSTSEntry) {
|
||||
if IPV4_REGEX.is_match(&entry.host) || IPV6_REGEX.is_match(&entry.host) {
|
||||
return
|
||||
}
|
||||
|
||||
let have_domain = self.has_domain(entry.host.clone());
|
||||
let have_subdomain = self.has_subdomain(entry.host.clone());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue