fix(wkt): panic in Duration deserialization - #6682
Conversation
When deserializing a Duration string with more than 9 fractional digits, `&pad[s.len()..]` would panic with an out-of-bounds byte index.
There was a problem hiding this comment.
Code Review
This pull request updates the Duration deserialization logic in src/wkt/src/duration.rs to handle fractional seconds exceeding 9 digits, adding validation for non-digit characters and empty nanoseconds, along with corresponding unit tests. The review feedback suggests optimizing the nanosecond parsing logic to avoid unnecessary heap allocations and string formatting overhead from format! by parsing the substring directly and mathematically scaling it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6682 +/- ##
=======================================
Coverage 96.66% 96.66%
=======================================
Files 308 308
Lines 97778 97803 +25
=======================================
+ Hits 94519 94544 +25
Misses 3259 3259 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
When deserializing a Duration string with more than 9 fractional digits,
&pad[s.len()..]would panic with an out-of-bounds byte index.