mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Raise ArgumentError if sprintf format string ends with %
* Add tests and specs. See ruby/spec#401. Patch by Yuta Iwama and Shintaro Morikawa. [ruby-core:80153] [Bug #13315] [Fix GH-1560] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e779eee98b
commit
fd8df3ab3d
3 changed files with 26 additions and 4 deletions
|
@ -520,7 +520,10 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
|||
VALUE sym = Qnil;
|
||||
|
||||
for (t = p; t < end && *t != '%'; t++) ;
|
||||
if (t + 1 == end) ++t;
|
||||
if (t + 1 == end) {
|
||||
if (*t == '%') rb_raise(rb_eArgError, "incomplete format specifier");
|
||||
++t;
|
||||
}
|
||||
PUSH(p, t - p);
|
||||
if (coderange != ENC_CODERANGE_BROKEN && scanned < blen) {
|
||||
scanned += rb_str_coderange_scan_restartable(buf+scanned, buf+blen, enc, &coderange);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue