From 33c3faa1252f2391ec456fa922ea2bf654f341b6 Mon Sep 17 00:00:00 2001 From: Bryce Glover Date: Fri, 14 Dec 2018 13:37:35 -0500 Subject: [PATCH] [`JavaRequirement#satisfies_version`] `java_version_s`: Fix regular expression. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The match obtained by applying the regular expression used to index into the `stderr` member of the result of calling `system_command` in the relevant variable assignment could yield unexpected results. The regular expression in- volved was not strict enough and contained an unescaped period, which could match any character, not just the expected literal decimal point. This commit corrects this oversight by escaping the relevant character, thus addressing @apjanke's remark in https://github.com/Homebrew/brew/pull/5280#issuecomment-437165119 on the existence of a: > …possible bug - that `.` looks like it should be escaped as `\.` to match a > literal ".".) … --- Library/Homebrew/requirements/java_requirement.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index e3c777cd83..bc59ea1f68 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -129,7 +129,7 @@ class JavaRequirement < Requirement end def satisfies_version(java) - java_version_s = system_command(java, args: ["-version"], print_stderr: false).stderr[/\d+.\d/] + java_version_s = system_command(java, args: ["-version"], print_stderr: false).stderr[/\d+\.\d/] return false unless java_version_s java_version = Version.create(java_version_s)