fix(cli): reject a project slug that cannot be typed back - #6879
Open
Chessing234 wants to merge 1 commit into
Open
fix(cli): reject a project slug that cannot be typed back#6879Chessing234 wants to merge 1 commit into
Chessing234 wants to merge 1 commit into
Conversation
validate_project_slug checked emptiness and length and nothing else, so a slug could carry a newline, a NUL, or a leading space. The slug is the d tag: it identifies the project, it is the value every later command filters #d on, and it is what projects list prints. A slug that differs from another only by an untypeable character therefore creates a second project that is indistinguishable from the first in a listing, and every later --slug on the visible spelling reports "not found" for a project the caller can see. Reject control characters and surrounding whitespace. Deliberately narrower than validate_repo_id's allowlist: project slugs are meant to be more permissive than repo ids (platform:v2 is a valid one), so this rejects only what cannot be typed back, not everything unusual. Interior spaces, colons and non-ASCII stay legal, and a test pins that. Signed-off-by: Taksh <takshkothari09@gmail.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.
Found by reading
validate_project_slugagainstvalidate_repo_id; no issue filed.validate_project_slugchecks emptiness and length and nothing else:The slug is the
dtag. It identifies the project (fetch_projectfilters{"kinds":[KIND_PROJECT],"authors":[..],"#d":[slug]}), it is the value every later--slugis matched on, and it is whatprojects listprints.So a slug can carry a newline, a tab, a NUL, or a leading space, and nothing downstream ever recovers it:
The project is right there in the listing, rendered as
platform, and every command that names it fails. Two projects that differ only by an untypeable character are indistinguishable in a listing and can only be told apart by reading the raw event. Because kind:30621 is addressable, the bad slug is also durable — it is the address, so there is no way to rename it, only to create the correct one alongside and delete the other.The change
Reject control characters and surrounding whitespace.
This is deliberately narrower than
validate_repo_id's[a-zA-Z0-9._-]allowlist. Project slugs are meant to be more permissive — the existing test assertsplatform:v2is legal, with the comment "colons allowed — more permissive than repo-id" — so this rejects only what cannot be typed back, not everything unusual.platform:v2,my project,équipeandteam_x.2all stay legal, and a test pins that so the rule can't quietly tighten into a repo-id clone later.Testing
cargo test -p buzz-cli --lib— 366 passed, 0 failed (three new cases: control characters rejected, surrounding whitespace rejected, permissive interior characters still accepted)cargo clippy -p buzz-cli --all-targets— cleancargo fmt --all -- --check— cleanNot run against a live relay. I have not checked whether the relay independently rejects a
dtag containing a control character — if it does, the effect today is a confusing relay-side error rather than a durable bad project, and this still moves the rejection to the argument where the message can name the actual problem.Related
Independent of #6877 and #6878 (UUID canonicalization in the same crate) — different function, different files, no shared symbols.