Skip to content

Fix panic on truncated strftime padding modifier#782

Merged
jhpratt merged 1 commit into
time-rs:mainfrom
SAY-5:fix-strftime-padding-oob
Jun 12, 2026
Merged

Fix panic on truncated strftime padding modifier#782
jhpratt merged 1 commit into
time-rs:mainfrom
SAY-5:fix-strftime-padding-oob

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Closes #781.

When a strftime format string ends right after a padding modifier (%_, %-, %0), the tokenizer reads self.input[2] for the component byte without checking that it exists, so parse_strftime_borrowed("%_") panics with an index-out-of-bounds instead of returning an error. This splits the padding match out and uses get(2) so a missing component yields the same Expected error the parser already returns elsewhere.

@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.3%. Comparing base (eb08b40) to head (ff5fce9).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
time/src/format_description/parse/strftime.rs 90.9% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #782     +/-   ##
=======================================
+ Coverage   88.2%   88.3%   +0.1%     
=======================================
  Files         99      99             
  Lines      13030   13073     +43     
=======================================
+ Hits       11494   11545     +51     
+ Misses      1536    1528      -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…modifier

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@jhpratt jhpratt force-pushed the fix-strftime-padding-oob branch from 7217e92 to ff5fce9 Compare June 12, 2026 04:58
@jhpratt jhpratt merged commit c57284f into time-rs:main Jun 12, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parse_strftime_borrowed panics on truncated padding modifier ("%_", "%-", "%0")

2 participants