The message unicode guard takes an allow list, read at the text seam too, and no entry on it can admit a character that draws nothing - #202
Conversation
…too, and no entry on it can admit a character that draws nothing `allow = ["U+FF01", ...]` is accepted on `prevent-unusual-unicode`, parsed with the codepoint half of the allowance the file guard already has. A message has no path, so an entry carrying the file guard's glob half is refused at load rather than read by nothing. A listed codepoint is admitted past the whitelist; a codepoint `is_invisible` refuses stays refused whatever the list says, and listing one is a load-time refusal naming it, so the allowance cannot open the zero-width and bidirectional hole that switching the whole rule off with `UPHOLD_ALLOW` opened. The field travels to the text seam on its own. `text-guards` dispatches through `over_text` to every built-in rule the effective policy holds, and hands `text_refusal` the rule as declared, inherited or shadowed, so a consumer that writes the allowance on `prevent-unusual-unicode` has it honoured for a pull-request body and a push, and `guard --text -` reads the same rule. The guard now reads `rule.allow()` where before it read only the id, and that is the whole of the plumbing. REFERENCE.md documents the field, that every Unicode whitespace (U+3000 included) and script-vouched punctuation already pass, and that an invisible is never allowable. No CJK-punctuation default is added. The nine consumer `allow = ["U+3000"]` lines were already redundant for U+3000 at the text seam, since `is_whitespace` admits it with or without a list. Closes #200
|
Warning Review limit reachedNext included review available in 13 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #202 +/- ##
==========================================
+ Coverage 93.63% 93.66% +0.02%
==========================================
Files 44 44
Lines 17057 17130 +73
==========================================
+ Hits 15971 16044 +73
Misses 1086 1086 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #200.
What is now true
allow = ["U+FF01", ...]is accepted onprevent-unusual-unicode, thecommit-msg and text guard. It is parsed with the codepoint half of the
allowance the file guard already has (
unicode::parse_codepoint, extractedfrom
parse_allowance); a message has no path, so an entry carrying theglob half is refused at load rather than read by nothing.
A listed codepoint is admitted past the whitelist. A codepoint
is_invisiblerefuses stays refused whatever the list says, and listing one is a load-time
refusal naming it (
rule "prevent-unusual-unicode": allow lists U+200B ZERO WIDTH SPACE, which draws nothing ...), so the allowance cannot open thezero-width and bidirectional hole the consumer's
UPHOLD_ALLOWexec lineopened. The invisibility test is asked at judgement time as well as at load,
so a
Rulethat never metvalidateadmits nothing by it either.How the field reaches the text seam
No new plumbing.
text-guardsdispatches throughguard::over_texttoevery built-in rule in the effective policy, and hands
text_refusalthe&Ruleas declared, inherited or shadowed.message::unusual_unicode_innow reads
rule.allow()where before it read only the id. So a consumerthat writes
[rule.prevent-unusual-unicode] allow = [...]beside its[inherit] sets = ["commit-message-residue", "published-text"]has theallowance honoured for a pull-request body and a push through
no-published-markers, anduphold guard --text -reads the same rule.Docs
REFERENCE.md gets the parameter row and a paragraph under the guard: every
Unicode whitespace passes (
is_whitespace, U+3000 included), script-vouchedpunctuation passes since 1.17.0, and an invisible is never allowable. No
CJK-punctuation default is added.
Tests
guard::message::tests: a listed codepoint is admitted and an unlistedone is not (through the loader); an invisible on the list is refused at
load and never admitted past it; a glob on a message allowance is refused
at load.
tests/text_cli.rs:guard --text -with a fixture declaringallow = ["U+FF01"]passes a body carrying U+FF01, the same body withoutthe allowance is refused, a body carrying U+200B is refused under both,
and a policy listing U+200B is exit 2 at load.
tests/shim_cli.rs: thetext-guardsconsultation honours the allowancedeclared on
prevent-unusual-unicodefor a-bbody and still refusesU+200B.
cargo test: 28 suites, 901 passed, 0 failed.cargo clippy --all-targets -- -D warnings,uphold check,uphold scanandbuild_reference.py --checkclean; lefthook pre-commit, commit-msg andpre-push all green.