pass full string_view to enum_from_string in value_to - #1201
Ramya-9353 wants to merge 1 commit into
Conversation
|
An automated preview of the documentation is available at https://1201.json.prtest2.cppalliance.org/libs/json/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-09-26 20:39:00 UTC |
|
GCOVR code coverage report https://1201.json.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-09-26 21:08:08 UTC |
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1201 +/- ##
========================================
Coverage 93.98% 93.98%
========================================
Files 85 85
Lines 8973 8973
========================================
Hits 8433 8433
Misses 540 540
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|

Repro:
value_to<E>()for a described enum, given a JSON string whose bytes are an enumerator name followed by an embeddedU+0000(e.g."admin\u0000x"), returns that enumerator instead of failing.parse_into<E>()rejects the same document withunknown_name.Cause: the described-enum handler calls
describe::enum_from_string(str->data(), val).str->data()is achar const*, which selects the overload that matches withstd::strcmp, so the name is truncated at the first null. The streamingparse_intoenum handler already passes astring_view, whose comparison spans the whole run, so the two APIs disagree on the same input.Fix: pass
str->subview()so thestring_viewoverload is selected and the full string, including any embedded null, is compared.Regression test added to
test/value_to.cpp:value_to<E1>of a two-byte string"a\0"throws before the change and is rejected after; the existing enum cases still pass.