I'm not sure why plus here should be ignored. But OK. Biodegradable test code:

auto answer = fast_float::parse_number_string<true>(
        f.data(), f.data() + f.size(),
        fast_float::parse_options(
            fast_float::chars_format::json |
            fast_float::chars_format::allow_leading_plus)); // should be ignored
    if (!answer.invalid) {
      std::cerr << "json parse accepted invalid json " << f << std::endl;
      return EXIT_FAILURE;
    }
This commit is contained in:
HedgehogInTheCPP 2026-09-19 23:14:01 +03:00
parent d577161969
commit 7ad87515ad

View File

@ -528,7 +528,8 @@ parse_number_string(UC const *p, UC const *pend,
// C++17 20.19.3.(7.1) explicitly forbids '+' sign here
answer.negative = *p == UC('-');
if (answer.negative ||
(chars_format_t(options.format & chars_format::allow_leading_plus) &&
(!json_fmt &&
chars_format_t(options.format & chars_format::allow_leading_plus) &&
*p == UC('+'))) {
++p;