various: proper escape in regex

This commit is contained in:
Xu Cheng 2016-07-13 15:58:04 +08:00
parent 48a1e1b47f
commit 91fb49d270
No known key found for this signature in database
GPG Key ID: C2A3860FA0B459CE
3 changed files with 3 additions and 3 deletions

View File

@ -142,7 +142,7 @@ class FormulaAuditor
swig swig
] ]
FILEUTILS_METHODS = FileUtils.singleton_methods(false).join "|" FILEUTILS_METHODS = FileUtils.singleton_methods(false).map { |m| Regexp.escape(m) }.join "|"
def initialize(formula, options = {}) def initialize(formula, options = {})
@formula = formula @formula = formula

View File

@ -238,7 +238,7 @@ module Homebrew
ignores = [] ignores = []
if f.deps.any? { |dep| dep.name == "go" } if f.deps.any? { |dep| dep.name == "go" }
ignores << %r{#{HOMEBREW_CELLAR}/go/[\d\.]+/libexec} ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/go/[\d\.]+/libexec}
end end
if ARGV.include? "--skip-relocation" if ARGV.include? "--skip-relocation"

View File

@ -110,7 +110,7 @@ class FormulaCreator
when %r{github\.com/\S+/(\S+)/archive/} when %r{github\.com/\S+/(\S+)/archive/}
@name = $1 @name = $1
else else
/(.*?)[-_.]?#{path.version}/.match path.basename /(.*?)[-_.]?#{Regexp.escape(path.version)}/.match path.basename
@name = $1 @name = $1
end end
end end