Escape paths in regexps
This commit is contained in:
parent
7e268670ed
commit
f8fb74ff76
@ -123,7 +123,7 @@ module Homebrew
|
|||||||
case path.to_s
|
case path.to_s
|
||||||
when HOMEBREW_TAP_PATH_REGEX
|
when HOMEBREW_TAP_PATH_REGEX
|
||||||
"#$1/#$2/#{File.basename($3, '.rb')}"
|
"#$1/#$2/#{File.basename($3, '.rb')}"
|
||||||
when %r{^#{HOMEBREW_LIBRARY}/Formula/(.+)}
|
when %r{^#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Formula/(.+)}o
|
||||||
"Homebrew/homebrew/#{File.basename($1, '.rb')}"
|
"Homebrew/homebrew/#{File.basename($1, '.rb')}"
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
@ -266,7 +266,7 @@ class Report
|
|||||||
def select_formula key
|
def select_formula key
|
||||||
fetch(key, []).map do |path|
|
fetch(key, []).map do |path|
|
||||||
case path.to_s
|
case path.to_s
|
||||||
when Regexp.new(HOMEBREW_LIBRARY + "/Formula")
|
when %r{^#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Formula}o
|
||||||
path.basename(".rb").to_s
|
path.basename(".rb").to_s
|
||||||
when HOMEBREW_TAP_PATH_REGEX
|
when HOMEBREW_TAP_PATH_REGEX
|
||||||
"#$1/#{$2.sub("homebrew-", "")}/#{path.basename(".rb")}"
|
"#$1/#{$2.sub("homebrew-", "")}/#{path.basename(".rb")}"
|
||||||
|
@ -3,6 +3,6 @@ HOMEBREW_TAP_ARGS_REGEX = %r{^([\w-]+)/(homebrew-)?([\w-]+)$}
|
|||||||
# match taps' formula, e.g. someuser/sometap/someformula
|
# match taps' formula, e.g. someuser/sometap/someformula
|
||||||
HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-]+)$}
|
HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-]+)$}
|
||||||
# match taps' directory path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap
|
# match taps' directory path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap
|
||||||
HOMEBREW_TAP_DIR_REGEX = %r{#{HOMEBREW_LIBRARY}/Taps/([\w-]+)/([\w-]+)}
|
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/([\w-]+)/([\w-]+)}
|
||||||
# match taps' formula path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula
|
# match taps' formula path, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula
|
||||||
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source)
|
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user