fix(repos): escape the path in create_or_update_file - #3429
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
A path containing # or ? was sent unescaped, so the file was written to the part of the path before that character (docs/C#/intro.md -> docs/C).
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.
Summary
create_or_update_filesent the file path into the request URL unescaped, so a path with#or?was cut there and the content was written to a different file. The path is now escaped segment by segment before the write.Why
Fixes #3427
go-github's
CreateFileputspathinto the URL as is, whileGetContents(used for the existence, SHA and symlink checks) escapes it. Sodocs/C#/intro.mdwas checked as the right file but written asdocs/C.What changed
CreateOrUpdateFilepassesescapeGitTreeish(path)toCreateFile.Test_CreateOrUpdateFile_EscapesPath: writesdocs/C#/intro?.mdand checks the PUT goes to.../contents/docs/C%23/intro%3F.md. Without the change the PUT goes to.../contents/docs/C.MCP impact
Paths with
#,?or%are written to the file that was asked for. No schema change.Prompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lintpins: 0 issues)go test ./...Docs