From e889daa21f6863abd4f100dd64e33ed5779b92eb Mon Sep 17 00:00:00 2001 From: Mustafa Gezen Date: Tue, 10 May 2022 12:02:37 +0200 Subject: [PATCH] Regex arguments should be escaped --- pkg/misc/regex.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/misc/regex.go b/pkg/misc/regex.go index 364e980..254b6f1 100644 --- a/pkg/misc/regex.go +++ b/pkg/misc/regex.go @@ -8,21 +8,21 @@ import ( ) func GetTagImportRegex(pd *data.ProcessData) *regexp.Regexp { - branchRegex := fmt.Sprintf("%s%d%s", pd.ImportBranchPrefix, pd.Version, pd.BranchSuffix) + branchRegex := regexp.QuoteMeta(fmt.Sprintf("%s%d%s", pd.ImportBranchPrefix, pd.Version, pd.BranchSuffix)) if !pd.StrictBranchMode { branchRegex += "(?:.+|)" } else { branchRegex += "(?:-stream-.+|)" } - initialVerRegex := filepath.Base(pd.RpmLocation) + "-" + initialVerRegex := regexp.QuoteMeta(filepath.Base(pd.RpmLocation)) + "-" if pd.PackageVersion != "" { - initialVerRegex += pd.PackageVersion + "-" + initialVerRegex += regexp.QuoteMeta(pd.PackageVersion) + "-" } else { initialVerRegex += ".+-" } if pd.PackageRelease != "" { - initialVerRegex += pd.PackageRelease + initialVerRegex += regexp.QuoteMeta(pd.PackageRelease) } else { initialVerRegex += ".+" }