From f4c27710d87af3652490cda63328715d44adb940 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 25 Aug 2019 12:15:41 +0200 Subject: [PATCH] Fix: Do not check via regex We do not need to check via regex here, because the previous checks are already more restrictive than the regex itself. Signed-off-by: Matthias Beyer --- lib/entry/libimagentrytag/src/tag.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/entry/libimagentrytag/src/tag.rs b/lib/entry/libimagentrytag/src/tag.rs index c9607bb5..58573cef 100644 --- a/lib/entry/libimagentrytag/src/tag.rs +++ b/lib/entry/libimagentrytag/src/tag.rs @@ -19,7 +19,6 @@ use std::result::Result; -use regex::Regex; use failure::Error; pub type Tag = String; @@ -37,9 +36,8 @@ pub fn is_tag_str(s: &String) -> Result<(), Error> { let is_lower = |s: &String| s.chars().all(|c| c.is_lowercase()); let no_whitespace = |s: &String| s.chars().all(|c| !c.is_whitespace()); let is_alphanum = |s: &String| s.chars().all(|c| c.is_alphanumeric()); - let matches_regex = |s: &String| Regex::new("^[a-zA-Z]([a-zA-Z0-9_-]*)$").unwrap().captures(s).is_some(); - if is_lower.and(no_whitespace).and(is_alphanum).and(matches_regex).filter(s) { + if is_lower.and(no_whitespace).and(is_alphanum).filter(s) { Ok(()) } else { Err(format_err!("The string '{}' is not a valid tag", s))