fix(cli): quote YAML frontmatter scalar values#132
Merged
chaliy merged 1 commit intoMay 18, 2026
Conversation
deb0360 to
a4a6ea5
Compare
a4a6ea5 to
b552a48
Compare
There was a problem hiding this comment.
Pull request overview
This PR hardens markdown YAML frontmatter generation in the CLI and MCP formatter by quoting untrusted scalar metadata before emitting it.
Changes:
- Added
yaml_quotehelpers using JSON string escaping. - Applied quoting to URL, content type, last modified, and filename frontmatter fields.
- Updated CLI tests and added a regression test for newline/YAML-special scalar injection.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/fetchkit-cli/src/main.rs |
Quotes frontmatter scalar metadata and updates unit coverage. |
crates/fetchkit-cli/src/mcp.rs |
Applies the same scalar quoting to MCP markdown output. |
crates/fetchkit-cli/tests/cli_integration.rs |
Updates expected CLI markdown output for quoted URLs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Motivation
Description
yaml_quotehelper that uses JSON string escaping to safely quote scalar values and returns a valid YAML string representation.yaml_quoteto theurl,source_content_type,last_modified, andfilenamefields in the CLI formatter incrates/fetchkit-cli/src/main.rsand the MCP formatter incrates/fetchkit-cli/src/mcp.rs.crates/fetchkit-cli/src/main.rsto expect quoted scalars and added a regression test that verifies newline and YAML-special payloads remain quoted and do not inject frontmatter keys.Testing
cargo fmt --allwhich completed successfully.cargo test -p fetchkit-cliand all tests passed (including the new regression test) with no failures.Codex Task