From 8802e8b4135c913f206508c8f7650a9f99ee6667 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 30 Jan 2023 09:17:33 +0000 Subject: [PATCH] v2v: Remove use of ~anchored In various places we used PCRE.compile ~anchored:true (PCRE2_ANCHORED) thinking it means that the regular expression is anchored at both ends. However this is not what it means (it only anchors the start). Replace with ^...$ (cherry picked from commit 8c316ed125e26583edc72eb9e953499b0078dcbd) --- in-place/in_place.ml | 4 ++-- inspector/inspector.ml | 4 ++-- v2v/v2v.ml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/in-place/in_place.ml b/in-place/in_place.ml index 55541814..f76651e6 100644 --- a/in-place/in_place.ml +++ b/in-place/in_place.ml @@ -29,8 +29,8 @@ open Types open Utils (* Matches --mac command line parameters. *) -let mac_re = PCRE.compile ~anchored:true "([[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}):(network|bridge|ip):(.*)" -let mac_ip_re = PCRE.compile ~anchored:true "([[:xdigit:]]|:|\\.)+" +let mac_re = PCRE.compile "^([[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}):(network|bridge|ip):(.*)$" +let mac_ip_re = PCRE.compile "^([[:xdigit:]]|:|\\.)+$" let rec main () = let set_string_option_once optname optref arg = diff --git a/inspector/inspector.ml b/inspector/inspector.ml index 13d58df3..d12d85c2 100644 --- a/inspector/inspector.ml +++ b/inspector/inspector.ml @@ -30,8 +30,8 @@ open Utils open DOM (* Matches --mac command line parameters. *) -let mac_re = PCRE.compile ~anchored:true "([[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}):(network|bridge|ip):(.*)" -let mac_ip_re = PCRE.compile ~anchored:true "([[:xdigit:]]|:|\\.)+" +let mac_re = PCRE.compile "^([[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}):(network|bridge|ip):(.*)$" +let mac_ip_re = PCRE.compile "^([[:xdigit:]]|:|\\.)+$" let rec main () = let set_string_option_once optname optref arg = diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 1e8d03ef..7a01eab5 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -34,8 +34,8 @@ open Types open Utils (* Matches --mac command line parameters. *) -let mac_re = PCRE.compile ~anchored:true "([[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}):(network|bridge|ip):(.*)" -let mac_ip_re = PCRE.compile ~anchored:true "([[:xdigit:]]|:|\\.)+" +let mac_re = PCRE.compile "^([[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}):(network|bridge|ip):(.*)$" +let mac_ip_re = PCRE.compile "^([[:xdigit:]]|:|\\.)+$" let rec main () = let set_string_option_once optname optref arg =