From d3c00b06b334311e23ab18f5d2b90938a07ce35d Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 6 Sep 2022 12:58:40 -0700 Subject: Fixes bug so that `%v` with modifiers doesn't compile. `%v` is not intended to work with modifiers because the meaning of modifiers is type-dependent and `%v` is intended to be used in situations where the type is not important. Please continue using if `%s` if you require format modifiers. PiperOrigin-RevId: 472534916 Change-Id: I5838761b2b40cbc4344077f23d44b1e634e5bae3 --- absl/strings/internal/str_format/checker.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'absl/strings/internal/str_format') diff --git a/absl/strings/internal/str_format/checker.h b/absl/strings/internal/str_format/checker.h index 2542f31d..aeb9d48d 100644 --- a/absl/strings/internal/str_format/checker.h +++ b/absl/strings/internal/str_format/checker.h @@ -212,6 +212,10 @@ class ConvParser { constexpr ConvParser ParseConversion() const { char first_char = GetChar(format_, 0); + if (first_char == 'v' && *(format_.data() - 1) != '%') { + return SetError(true); + } + if (is_positional_) { return VerifyPositional({ConsumeFront(format_), arg_position_}, first_char); -- cgit v1.2.3