summaryrefslogtreecommitdiff
path: root/absl/strings/internal/str_format/parser_test.cc
diff options
context:
space:
mode:
authorGravatar Andy Soffer <asoffer@google.com>2022-10-10 14:53:27 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-10-10 14:54:32 -0700
commit845610e80b66aa3d834f4d1b401133919bf7fadb (patch)
treeb785139b62abd6770a80d253c2ed9640d9c0a60b /absl/strings/internal/str_format/parser_test.cc
parenta0b5e3273bf6780b83c6e7fab23a5a92d6a005b7 (diff)
Fix a bug in StrFormat. This issue would have been caught by any compile-time
checking but can happen for incorrect formats parsed via ParsedFormat::New. Specifically, if a user were to add length modifiers with 'v', for example the incorrect format string "%hv", the ParsedFormat would incorrectly be allowed. PiperOrigin-RevId: 480183817 Change-Id: I8510c13189fdf807cdaa7f2e1b7ed9fba2aaefb9
Diffstat (limited to 'absl/strings/internal/str_format/parser_test.cc')
-rw-r--r--absl/strings/internal/str_format/parser_test.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/absl/strings/internal/str_format/parser_test.cc b/absl/strings/internal/str_format/parser_test.cc
index fe0d2963..c3e825fe 100644
--- a/absl/strings/internal/str_format/parser_test.cc
+++ b/absl/strings/internal/str_format/parser_test.cc
@@ -110,10 +110,13 @@ TEST_F(ConsumeUnboundConversionTest, ConsumeSpecification) {
{__LINE__, "ba", "", "ba"}, // 'b' is invalid
{__LINE__, "l", "", "l" }, // just length mod isn't okay
{__LINE__, "d", "d", "" }, // basic
+ {__LINE__, "v", "v", "" }, // basic
{__LINE__, "d ", "d", " " }, // leave suffix
{__LINE__, "dd", "d", "d" }, // don't be greedy
{__LINE__, "d9", "d", "9" }, // leave non-space suffix
{__LINE__, "dzz", "d", "zz"}, // length mod as suffix
+ {__LINE__, "3v", "", "3v"}, // 'v' cannot have modifiers
+ {__LINE__, "hv", "", "hv"}, // 'v' cannot have modifiers
{__LINE__, "1$*2$d", "1$*2$d", "" }, // arg indexing and * allowed.
{__LINE__, "0-14.3hhd", "0-14.3hhd", ""}, // precision, width
{__LINE__, " 0-+#14.3hhd", " 0-+#14.3hhd", ""}, // flags