Skip to content

Commit

Permalink
Regex arguments should be escaped
Browse files Browse the repository at this point in the history
  • Loading branch information
mstg committed May 10, 2022
1 parent 3f4c4ad commit e889daa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/misc/regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 += ".+"
}
Expand Down

0 comments on commit e889daa

Please sign in to comment.