1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Reject command line option ending with -

This commit is contained in:
Nobuyoshi Nakada 2022-01-11 11:45:24 +09:00
parent 8b585f7460
commit 1c9b5d452e
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 4 additions and 1 deletions

3
ruby.c
View file

@ -1460,7 +1460,8 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
# define is_option_with_arg(name, allow_hyphen, allow_envopt) \
is_option_with_optarg(name, allow_hyphen, allow_envopt, Qtrue, Qtrue)
# define is_option_with_optarg(name, allow_hyphen, allow_envopt, needs_arg, next_arg) \
(strncmp((name), s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], (allow_hyphen)) ? \
(strncmp((name), s, n = sizeof(name) - 1) == 0 && is_option_end(s[n], (allow_hyphen)) && \
(s[n] != '-' || s[n+1]) ? \
(check_envopt(name, (allow_envopt)), s += n, \
need_argument(name, s, needs_arg, next_arg), 1) : 0)

View file

@ -121,6 +121,8 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["--disable-gems", "--debug", "-e", "p $DEBUG"],
"", %w(true), [])
assert_in_out_err(["--disable-gems", "--debug-", "-e", "p $DEBUG"], "", %w(), /invalid option --debug-/)
end
q = Regexp.method(:quote)