Skip to content

Commit 3fc6249

Browse files
committed
Match more strictly with \A and \z
1 parent b939495 commit 3fc6249

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

generate-windows-versions.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
# - Each path component must begin with [\w], or a more restrictive character set.
99
# - Percent (`%`) shall not be allowed to avoid any percent encoding.
1010
WINDOWS_VERSIONS_URLS_REGEXPS = [
11-
%r{^https://github\.com/oneclick/rubyinstaller2?/releases/download/\w[\w.-]*/\w[\w.-]*$},
12-
%r{^https://github\.com/MSP-Greg/ruby-loco/releases/download/\w[\w.-]*/\w[\w.-]*$}
11+
%r{\Ahttps://github\.com/oneclick/rubyinstaller2?/releases/download/\w[\w.-]*/\w[\w.-]*\z},
12+
%r{\Ahttps://github\.com/MSP-Greg/ruby-loco/releases/download/\w[\w.-]*/\w[\w.-]*\z}
1313
].freeze
1414

1515
WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS = [
16-
%r{^https://github\.com/oneclick/rubyinstaller/releases/download/devkit-4\.7\.2/DevKit-mingw64-64-4\.7\.2-20130224-1432-sfx\.exe$},
17-
%r{^https://github\.com/ruby/setup-msys2-gcc/releases/download/\w[\w.-]*/\w[\w@.-]*$},
18-
%r{^https://github\.com/ruby/setup-msys2-gcc/releases/latest/download/\w[\w@.-]*$}
16+
%r{\Ahttps://github\.com/oneclick/rubyinstaller/releases/download/devkit-4\.7\.2/DevKit-mingw64-64-4\.7\.2-20130224-1432-sfx\.exe\z},
17+
%r{\Ahttps://github\.com/ruby/setup-msys2-gcc/releases/download/\w[\w.-]*/\w[\w@.-]*\z},
18+
%r{\Ahttps://github\.com/ruby/setup-msys2-gcc/releases/latest/download/\w[\w@.-]*\z}
1919
].freeze
2020

2121
# Validate all the URLs in the versions json
2222
def validate(versions, allowed_urls_regexps)
2323
versions.values.flat_map(&:values).each do |url|
24-
if allowed_urls_regexps.none? { |regexp| regexp =~ url }
24+
if allowed_urls_regexps.none? { |regexp| regexp.match? url }
2525
raise SecurityError, "Unexpected URL: #{url}"
2626
end
2727
end

0 commit comments

Comments
 (0)