sync_default_gems.rb: check message_filter arguments

This commit is contained in:
Nobuyoshi Nakada 2022-12-19 22:45:10 +09:00
parent 060ae17c80
commit 4180036f48
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2025-01-13 01:55:32 +00:00

View File

@ -471,6 +471,12 @@ module SyncDefaultGems
end
def message_filter(repo, sha, input: ARGF)
unless repo.count("/") == 1 and /\A\S+\z/ =~ repo
raise ArgumentError, "invalid repository: #{repo}"
end
unless /\A\h{10,40}\z/ =~ sha
raise ArgumentError, "invalid commit-hash: #{sha}"
end
log = input.read
log.delete!("\r")
log << "\n" if !log.end_with?("\n")