Skip to content

Percent-encode file paths in blob finding links - #566

Merged
mickgmdb merged 1 commit into
mongodb:mainfrom
RaphaelFakhri:fix/encode-blob-file-url-paths
Oct 26, 2026
Merged

mickgmdb merged 1 commit into
mongodb:mainfrom
RaphaelFakhri:fix/encode-blob-file-url-paths

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Summary

build_git_urls builds the default (GitHub-style) file link as {repo}/blob/{commit}/{path}#L{line} with the raw path. When the path contains #, ?, % or a space, the link breaks: the browser reads the rest of the path as a fragment or query, so it opens the wrong file and drops the line anchor. For example, src/C#/appsettings.json links to src/C.

This change percent-encodes the path for the default link. It uses the same character set that the Bitbucket and Azure DevOps branches already use, minus |, and keeps / separators. Paths without special characters produce the same URLs as before.

Fixes #565

Test plan

  • New unit test reporter::tests::blob_links_percent_encode_file_paths. It fails on main (the link contains src/C#/100% done?.txt) and passes with this change.
  • cargo test --lib -- reporter::: 47 passed.
  • cargo test --lib: 867 passed, 1 failed. scanner::roots::tests::expand_repo_roots_skips_unreadable_directories fails only because the run was as root, which can read the "unreadable" directory. The test is in src/scanner/roots.rs and does not touch link building.
  • cargo fmt --all -- --check
  • cargo clippy -p kingfisher-bin --lib --tests -- -D warnings

Paths containing #, ?, % or spaces produced GitHub-style file URLs that
browsers cut at the first # or ? and that pointed at the wrong file.
Encode the blob path the same way the Bitbucket and Azure links already do.
Copilot AI balanced review requested due to automatic review settings October 24, 2026 16:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow change addresses the reported URL corruption with focused regression coverage and no unresolved findings.

No open issues 🎉

Review effort: Balanced

@mickgmdb
mickgmdb merged commit d998f30 into mongodb:main Oct 26, 2026
31 of 32 checks passed
@mickgmdb mickgmdb mentioned this pull request Oct 27, 2026
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.

File URLs in git findings break when the path contains #, ?, % or spaces

3 participants