Encode '+' in URL path segments to support SemVer build metadata #1541
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.
Semantic Versioning lets us use "+" for build metadata (like 1.0.0+10), but AWS S3 sees "+" as a space even in URL path segments, which causes 403 errors when we try to access extension resources. This change makes sure that '+' is always encoded as '%2B' when building API URLs in UrlUtil.createApiUrl. This keeps Semantic Versioning the same.
In short It was possible to publish extensions that used Semantic Versioning with build metadata (for example, 1.0.0+10), but later they wouldn't load or download, which caused 403 errors. The + sign in URLs is treated as a space by AWS S3, even in path segments.
UriUtils.encodePathSegment not encoding the + character when making API URLs was the cause of the problem. Because of this, URLs with versions that had + were made wrong for resources that were backed by S3. When making URL path segments, this change fixes the problem by explicitly encoding + as %2B in UrlUtil.createApiUrl. The fix is applied in one place, so it affects all API URLs in the same way, without changing Semantic Versioning.