Blob Blame History Raw
From 628ee708464ee3d266609167c48e92f883849e4d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 30 Jan 2023 09:01:38 +0000
Subject: [PATCH] -o kubevirt: Replace PCRE ~anchored with ^...$

Because this regexp was not anchored at both ends it would still
report a match for incorrect names.

Fixes: commit 8a9c914544a49bed13eb5baf42290f835bdee7b5
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2162332
Reported-by: Ming Xie

Cherry picked from commit 050a0ba714ddf2a5d81515c886032016aa75342c.
I did not include the update to the common module since picking that
would pull in the large changes made to the virtio driver code.
---
 output/output_kubevirt.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/output/output_kubevirt.ml b/output/output_kubevirt.ml
index ee89fdbf..fdf0f279 100644
--- a/output/output_kubevirt.ml
+++ b/output/output_kubevirt.ml
@@ -31,8 +31,8 @@ open Create_kubevirt_yaml
 
 (* Valid output names for Kubevirt (RHBZ#2162332). *)
 let rfc1123_re =
-  PCRE.compile ~anchored:true
-    "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"
+  PCRE.compile
+    "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"
 
 module Kubevirt = struct
   type poptions = bool * output_allocation * string * string * string