mirror of
https://framagit.org/ppom/reaction
synced 2026-03-14 12:45:47 +01:00
ipv4 regex: do no accept numbers 0[0-9]
The Rust std won't accept it anyway, as it interprets numbers starting with 0 as octal numbers and forbid that.
This commit is contained in:
parent
0b2bfe533b
commit
cebdbc7ad0
2 changed files with 4 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ impl PatternType {
|
|||
// then 1xx
|
||||
"1[0-9][0-9]",
|
||||
// then 0xx
|
||||
"[0-9][0-9]",
|
||||
"[1-9][0-9]",
|
||||
// then 0x
|
||||
"[0-9])",
|
||||
]
|
||||
|
|
@ -641,6 +641,7 @@ mod patternip_tests {
|
|||
assert2!(!regex.is_match("1.2.3.4 "));
|
||||
assert2!(!regex.is_match("1.2. 3.4"));
|
||||
assert2!(!regex.is_match("257.2.3.4"));
|
||||
assert2!(!regex.is_match("074.2.3.4"));
|
||||
assert2!(!regex.is_match("1.2.3.4.5"));
|
||||
assert2!(!regex.is_match("1.2..4"));
|
||||
assert2!(!regex.is_match("1.2..3.4"));
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ mod utils_tests {
|
|||
normalize("::ffff:1.2.3.4"),
|
||||
Ok(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4)))
|
||||
);
|
||||
// octal numbers are forbidden
|
||||
assert!(normalize("083.44.23.14").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue