Skip to content

Restrict package-script trimming to ASCII whitespace - #56

Merged
hzw0813 merged 6 commits into
mainfrom
fix/ascii-only-script-trim
Aug 15, 2026
Merged

Restrict package-script trimming to ASCII whitespace#56
hzw0813 merged 6 commits into
mainfrom
fix/ascii-only-script-trim

Conversation

@hzw0813

@hzw0813 hzw0813 commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace JavaScript String.trim() in Node and Jest/Vitest package-script recognition with ASCII space/tab-only edge trimming
  • keep ordinary shell-significant space/tab padding supported
  • fail closed on leading or trailing non-ASCII whitespace such as NBSP instead of silently erasing it into a different recognized command
  • add Node and Jest regressions for both accepted ASCII padding and rejected Unicode edge whitespace
  • regenerate tracked dist and document the boundary in the changelog

Why

The parsers already normalized only [ \t]+ internally after the multiline hardening, but both still called String.trim() first. JavaScript trim() removes a wider Unicode whitespace set, including NBSP. A package script such as node --test\u00a0 or \u00a0jest --ci could therefore be normalized by ProofDiff into a supported exact-target command even though that non-ASCII character is not ordinary shell separator whitespace. That creates a semantic mismatch between the repository script and the targeted command ProofDiff actually runs.

The fix narrows edge trimming to exactly spaces and tabs, matching the parser's existing internal normalization boundary.

Verification

  • full npm test passed after the change
  • clean npm run clean && npm run build passed
  • final branch diff contains only source, tests, changelog, and regenerated dist; temporary updater files were removed

@hzw0813
hzw0813 merged commit 67c20f9 into main Aug 15, 2026
13 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.

1 participant