Fix double URL-encoding of paths with spaces in category-p2-metadata#6120
Open
renemuehle wants to merge 1 commit into
Open
Fix double URL-encoding of paths with spaces in category-p2-metadata#6120renemuehle wants to merge 1 commit into
renemuehle wants to merge 1 commit into
Conversation
CategoryP2MetadataMojo passes the metadata repository and category definition locations as already-encoded URI strings (toURI/toURL/ toExternalForm) to CategoryPublisherApplication, which parses them with URIUtil.fromString(String). That method is documented for *unencoded* strings and warns it must not be called with an already-encoded URI, as the escape character '%' gets escaped itself. The space's %20 thus becomes %2520 and the publisher fails with "P2 publisher return code was 1": ProvisionException: Error reading update site file:/.../my%2520site/category.xml Use URIUtil.toUnencodedString(URI), the documented counterpart of URIUtil.fromString, so producer and consumer use the matching convention. Signed-off-by: Rene Muehle <renemuehle@gmail.com>
Member
|
@renemuehle can you provide an integration-test to demonstrate the issue and make sure it does not brake in the future? |
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.
Problem
tycho-p2-plugin:category-p2-metadatafails when the build/output path contains a space(or any character requiring percent-encoding), e.g. a Jenkins workspace named
My Build:ProvisionException: Error reading update site file:/.../my%2520site/category.xml
-> "P2 publisher return code was 1"
Root cause
CategoryP2MetadataMojo#addArgumentsemits the-metadataRepository/-categoryDefinitionarguments via
toURI().toURL().toExternalForm()— an encoded URI string (space →%20).CategoryPublisherApplication/AbstractPublisherApplicationthen parse them withorg.eclipse.core.runtime.URIUtil.fromString(String), whose javadoc states it is forunencoded strings and:
So
%20is re-encoded to%2520, and the publisher looks for a non-existent directoryliterally named
my%20site.Fix
Use
URIUtil.toUnencodedString(URI)— the documented counterpart ofURIUtil.fromString—so producer and consumer use the matching encoding convention. Verified that the same
fromStringlogic then yields correct single-encoding on both Windows and Linux.Reproduction (independent of any wrapper plugin)
content.jar+artifacts.jar) and acategory.xml, placed undera directory whose absolute path contains a space, e.g.
.../my site/repository/.tycho-p2-plugin:category-p2-metadatawithtarget= that repo dir andcategoryDefinition= thatcategory.xml.Affected
Reproduced with 5.0.3; the offending code is unchanged on
main.Related: #5939, #652 (same family of path-encoding issues, different code path).