fix: handle NUL and vertical tab characters in source - #425
Draft
toddr-bot wants to merge 2 commits into
Draft
Conversation
PPI throws "Encountered unexpected character '0'" when parsing Perl source containing NUL (ASCII 0) or vertical tab (ASCII 11) characters, even though Perl itself handles them fine. These tests verify that PPI can parse such source code, preserve the characters as whitespace tokens, and round-trip them correctly. Tests are marked $TODO since the fix is not yet implemented. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Perl tolerates NUL (ASCII 0) and vertical tab (ASCII 11) characters in source code, but PPI threw "Encountered unexpected character" for both. Add them to the tokenizer's whitespace character map so they are parsed as PPI::Token::Whitespace, preserving round-trip fidelity. Also escape \0 and \v in Dumper output for readability. Fixes #69 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.
Summary
PPI threw "Encountered unexpected character '0'" when parsing Perl source containing NUL (ASCII 0) or vertical tab (ASCII 11) characters, even though
perlitself runs such code fine. This adds both characters to the tokenizer's whitespace character map so they are parsed asPPI::Token::Whitespace, preserving round-trip fidelity.Fixes #69
Changes
%CLASSMAPinPPI::Token::Whitespaceas whitespace characters\0and\vescaping inPPI::Dumperoutput for readabilityTest plan
Generated by Kōan /fix
Quality Report
Changes: 3 files changed, 34 insertions(+), 1 deletion(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline