diff --git a/src/concepts/pattern/ip/mod.rs b/src/concepts/pattern/ip/mod.rs index 2fdfd80..3bf727c 100644 --- a/src/concepts/pattern/ip/mod.rs +++ b/src/concepts/pattern/ip/mod.rs @@ -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")); diff --git a/src/concepts/pattern/ip/utils.rs b/src/concepts/pattern/ip/utils.rs index a294c55..2e1ad66 100644 --- a/src/concepts/pattern/ip/utils.rs +++ b/src/concepts/pattern/ip/utils.rs @@ -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]