fix: decode URL-encoded characters in asset filenames#569
Open
fix: decode URL-encoded characters in asset filenames#569
Conversation
Fixes helm#281 GitHub encodes special characters in asset URLs (e.g., `+` becomes `%2B`). When processing charts with SemVer build metadata like `1.0.0+build.1`, chart-releaser would fail because it tried to access files using the URL-encoded filename instead of the actual filename on disk. This change adds URL decoding in two critical locations: - UpdateIndexFile(): when extracting filenames from asset URLs - addToIndexFile(): when constructing local file paths Both the filename used for filesystem operations and the name stored in the index file are now properly decoded, ensuring consistency. Added comprehensive test coverage including a test chart package with build metadata to verify the fix works end-to-end. Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
1c72bf2 to
b0c0bf7
Compare
Author
|
@cpanato can you have a look please? |
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.
Fix URL-encoded characters in asset filenames
Problem
Closes #281
Chart packages with SemVer build metadata (e.g.,
cloudbees-core-3.11627+2e5eff15bf01.tgz) cause chart-releaser to crash.Root cause: GitHub encodes special characters in asset URLs (
+→%2B). When chart-releaser processes these URLs, it tries to access files using the encoded name (file%2Bversion.tgz) instead of the actual filename on disk (file+version.tgz), resulting in "file not found" errors.Solution
This PR adds URL decoding at two critical points in the release processing pipeline:
UpdateIndexFile()- Decodes the filename when extracting it from the asset URLaddToIndexFile()- Decodes the filename when constructing the local file pathThis ensures consistency between:
Changes
Core Implementation
url.PathUnescape()to decode filenames inUpdateIndexFile()(releaser.go:167-170)url.PathUnescape()to decode filenames inaddToIndexFile()(releaser.go:263-269)Test Coverage
index-file-with-url-encoded-plus-signtest-chart-0.1.0+build.1.tgzTesting
All existing tests pass, plus new test coverage for URL encoding:
$ go test ./pkg/releaser ok github.com/helm/chart-releaser/pkg/releaser 0.016s