Title: fix(raw): escape path segments when building raw content URLs by sarankumar1325 · Pull Request #3615 · github/github-mcp-server · GitHub
Open Graph Title: fix(raw): escape path segments when building raw content URLs by sarankumar1325 · Pull Request #3615 · github/github-mcp-server
X Title: fix(raw): escape path segments when building raw content URLs by sarankumar1325 · Pull Request #3615 · github/github-mcp-server
Description: Summary repo:// resource reads now percent-encode each path segment before building the raw.githubusercontent.com URL, so file names containing % are fetched exactly as named. Why Fixes #3614 raw.Client passed the decoded owner/repo/ref/path to url.URL.JoinPath, which treats its arguments as already escaped. A.txt was fetched as A.txt, and 100%.txt (an invalid escape) made JoinPath quietly fall back to the base URL, so the resource returned GitHub's homepage HTML as the file content. What changed pkg/raw/raw.go: new escapePathSegments helper applies url.PathEscape to every /-separated segment of owner, repo, ref/sha and path before JoinPath in refURL and commitURL. The existing .. traversal rejection runs first and is unchanged. pkg/raw/raw_test.go: cases for docs/100%.txt, A.txt, % with a SHA, and space/#/?/unicode in a ref and path. The old benign percent-encoded filename allowed case expected .hidden to go out unescaped, which actually requested .hidden. It now expects %2ehidden. pkg/github/repository_resource_test.go: handler-level test that repo://owner/repo/contents/docs/100%.txt and .../%41.txt request /owner/repo/HEAD/docs/100%.txt and /owner/repo/HEAD/A.txt. Both fail on main (one errors, one requests A.txt). MCP impact No tool or API changes. Only the URL the repository resource handler fetches changes, and only for names containing characters that need escaping. Tool schema or behavior changed New tool added Prompts tested (tool changes only) N/A (no tool changes) Security / limits No security or limits impact Auth / permissions considered. Path traversal checks (rejectPathTraversal) still run on the unescaped input before escaping, and escaping means an encoded .. can no longer be decoded by JoinPath. Data exposure, filtering, or token/size limits considered Tool renaming I am renaming tools as part of this PR (e.g. a part of a consolidation effort) I have added the new tool aliases in deprecated_tool_aliases.go I am not renaming tools as part of this PR Lint & tests Linted locally with ./script/lint (gofmt -s and golangci-lint v2.14.0: 0 issues) Tested locally with ./script/test (go test ./... passes) Docs Not needed Updated (README / docs / examples) I used an AI assistant to write this change. I reviewed the diff and ran the tests above.
Open Graph Description: Summary repo:// resource reads now percent-encode each path segment before building the raw.githubusercontent.com URL, so file names containing % are fetched exactly as named. Why Fixes #3614 raw.C...
X Description: Summary repo:// resource reads now percent-encode each path segment before building the raw.githubusercontent.com URL, so file names containing % are fetched exactly as named. Why Fixes #3614 raw.C...
Opengraph URL: https://github.com/github/github-mcp-server/pull/3615
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:7298784e-11a3-99ee-75ae-6761400048ec |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 815A:44613:10608A:162D18:6B05D0E8 |
| html-safe-nonce | 13a6c01c1b38941a9aa9cf65a57575d7269eb098a9cc6441e418fe9c85101853 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTVBOjQ0NjEzOjEwNjA4QToxNjJEMTg6NkIwNUQwRTgiLCJ2aXNpdG9yX2lkIjoiMzIxOTAyNjkyNzI4MTM2MTEyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 90a6f2d6403411d30420b0e24a7f430d1ee611fce2d4b0d8bb7509acad4a299a |
| hovercard-subject-tag | pull_request:5067992811 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/github/github-mcp-server/pull/3615/files |
| twitter:image | https://avatars.githubusercontent.com/u/120080287?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/120080287?s=400&v=4 |
| og:image:alt | Summary repo:// resource reads now percent-encode each path segment before building the raw.githubusercontent.com URL, so file names containing % are fetched exactly as named. Why Fixes #3614 raw.C... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 08d6d51500e13cdaf71a9aad37c03e883f1143f9325056e77a14fa0d06d5bf64 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/github/github-mcp-server git https://github.com/github/github-mcp-server.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 942771284 |
| octolytics-dimension-repository_nwo | github/github-mcp-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 942771284 |
| octolytics-dimension-repository_network_root_nwo | github/github-mcp-server |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 839b69d5acfb3181bc844f20b9848f74b957add3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width