fix: strptime day-name removal fails for non-ASCII byte encodings#106
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: strptime day-name removal fails for non-ASCII byte encodings#106Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
The \b word boundary anchor in the strptime parser's day-name removal regex does not work with non-ASCII single-byte encodings (KOI8-R, CP1251, GB2312). Perl's \b checks \w/\W boundaries using ASCII rules, so high bytes (>0x7F) are all classified as \W — making \b never match between a non-ASCII day name and the following space. This broke ctime/str2time round-trips for Russian, Russian_cp1251, Russian_koi8r, and Chinese_GB language modules. Fix: replace \s*...\b with \s+ (require at least one space after the day name). Day names in date strings are always separated by whitespace, so requiring \s+ correctly prevents partial matches (e.g. "mar" inside French "mars") while working for all encodings. Also extends t/lang.t to test all 36 language modules for round-trip correctness (was 18, now 36). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix strptime parser failing to strip day names in non-ASCII single-byte encodings (KOI8-R, CP1251, GB2312).
Why
Perl's
\bword boundary uses ASCII-only\w/\Wclassification. High bytes (>0x7F) are all\W, so\bnever fires between a non-ASCII day name and the following space. This brokectime/str2timeround-trips for Russian, Russian_cp1251, Russian_koi8r, and Chinese_GB language modules.How
Replace
\s*...\bwith\s+in the day-name removal regex (line 87 of Parse.pm). Day names in date strings are always word-separated, so requiring at least one trailing space correctly prevents partial matches (e.g. French "mar" inside "mars") while working for all encodings.Testing
t/lang.tfrom 18 to all 36 language modules for round-trip coverage\bwas protecting)🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 8 insertions(+), 6 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline