diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java b/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java index 6cac3626e3..17431f268d 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java @@ -20,11 +20,8 @@ package org.apache.maven.project.processor; */ -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URLDecoder; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -100,21 +97,6 @@ public abstract class BaseProcessor implements Processor return parent; } - protected String decodeUrl(String uri) - { - if(uri == null) - { - return null; - } - - try { - return URLDecoder.decode(uri, "UTF-8"); - } catch (UnsupportedEncodingException e) { - return null; - } - - } - protected String normalizeUriWithRelativePath(String u, String artifactId, Model parent) { if(u == null) @@ -132,7 +114,7 @@ public abstract class BaseProcessor implements Processor { normalized = normalized.replaceFirst("/", slashes); } - return decodeUrl(normalized); + return normalized; } catch (URISyntaxException e) { @@ -164,7 +146,7 @@ public abstract class BaseProcessor implements Processor List modules = moduleProject.getModules(); if (modules != null) { for (Iterator it = modules.iterator(); it.hasNext();) { - String modulePath = (String) it.next(); + String modulePath = it.next(); String moduleName = modulePath; if (moduleName.endsWith("/") || moduleName.endsWith("\\")) { diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java b/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java index 34c95b87bb..0ceab00a7e 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java @@ -19,10 +19,6 @@ package org.apache.maven.project.processor; * under the License. */ -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLDecoder; - import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Model; @@ -124,7 +120,7 @@ public class DistributionManagementProcessor if ( target.getUrl() == null ) { - target.setUrl( decodeUrl(source.getUrl()) ); + target.setUrl( source.getUrl() ); } if ( target.getName() == null ) @@ -151,7 +147,7 @@ public class DistributionManagementProcessor { if ( isChild ) { - target.setUrl( decodeUrl(source.getUrl()) ); + target.setUrl( source.getUrl() ); } else { @@ -160,7 +156,7 @@ public class DistributionManagementProcessor } else { - target.setUrl( decodeUrl(target.getUrl() + (target.getUrl().endsWith("/") ? "" : "/")+ artifactId) ); + target.setUrl( target.getUrl() + (target.getUrl().endsWith("/") ? "" : "/")+ artifactId ); } } diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java b/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java index 80ffd94f52..a54b939aa4 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java @@ -19,7 +19,6 @@ package org.apache.maven.project.processor; * under the License. */ -import java.net.URLDecoder; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -124,7 +123,7 @@ public class ModelProcessor if ( c.getUrl() != null ) { - t.setUrl(decodeUrl(c.getUrl())); + t.setUrl( c.getUrl() ); } else if(p != null && p.getUrl() != null) { @@ -132,7 +131,7 @@ public class ModelProcessor } else if (t.getUrl() != null) { - t.setUrl( decodeUrl(t.getUrl() + "/" + t.getArtifactId()) ); + t.setUrl( t.getUrl() + "/" + t.getArtifactId() ); } //Dependencies diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java b/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java index f54787f16e..ab65aa6661 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java @@ -19,10 +19,6 @@ package org.apache.maven.project.processor; * under the License. */ -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLDecoder; - import org.apache.maven.model.Model; import org.apache.maven.model.Scm; @@ -55,14 +51,14 @@ public class ScmProcessor extends BaseProcessor { if(c != null && c.getUrl() != null) { - t.setUrl(decodeUrl(c.getUrl()) ); + t.setUrl( c.getUrl() ); } else if(p != null && p.getUrl() != null) { t.setUrl( normalizeUriWithRelativePath(p.getUrl(), artifactId, parent)); } else if(t.getUrl() != null) { - t.setUrl( decodeUrl(t.getUrl() + "/" + artifactId) ); + t.setUrl( t.getUrl() + "/" + artifactId ); } } @@ -70,14 +66,14 @@ public class ScmProcessor extends BaseProcessor { if(c!= null && c.getConnection() != null) { - t.setConnection(decodeUrl(c.getConnection())); + t.setConnection( c.getConnection() ); } else if(p != null && p.getConnection() != null) { t.setConnection( normalizeUriWithRelativePath(p.getConnection(), artifactId, parent)); } else if(t.getConnection() != null) { - t.setConnection( decodeUrl(t.getConnection() + "/" + artifactId) ); + t.setConnection( t.getConnection() + "/" + artifactId ); } } @@ -85,14 +81,14 @@ public class ScmProcessor extends BaseProcessor { if(c!= null && c.getDeveloperConnection() != null) { - t.setDeveloperConnection(decodeUrl(c.getDeveloperConnection())); + t.setDeveloperConnection( c.getDeveloperConnection() ); } else if(p != null && p.getDeveloperConnection() != null) { t.setDeveloperConnection( normalizeUriWithRelativePath(p.getDeveloperConnection(), artifactId, parent) ); } else if(t.getDeveloperConnection() != null){ - t.setDeveloperConnection( decodeUrl(t.getDeveloperConnection() + "/" + artifactId) ); + t.setDeveloperConnection( t.getDeveloperConnection() + "/" + artifactId ); } } diff --git a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java index a129714765..0ef63c298e 100644 --- a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -768,7 +768,7 @@ public class PomConstructionTest testAppendOfInheritedPluginConfiguration( "no-profile" ); } - /* FIXME: MNG-2591*/ + /* MNG-2591*/ public void testAppendOfInheritedPluginConfigurationWithActiveProfile() throws Exception { @@ -928,15 +928,7 @@ public class PomConstructionTest assertEquals("https://scm.project.url/child", pom.getValue( "scm/developerConnection" )); assertEquals("http://site.project.url/child", pom.getValue( "distributionManagement/site/url" )); } - - /** MNG-4087 */ - public void testPercentEncodedUrl() - throws Exception - { - PomTestWrapper pom = this.buildPom( "percent-encoded-url" ); - assertEquals("@baseurl@/target/repo", pom.getValue( "distributionManagement/repository/url" )); - } - + /** MNG-0479 */ public void testRepoInheritance() throws Exception @@ -1301,7 +1293,26 @@ public class PomConstructionTest assertEquals("0.2", pom.getValue( "build/extensions[2]/version" ) ); assertEquals("c", pom.getValue( "build/extensions[3]/artifactId" ) ); } - + + /** MNG-4116 */ + public void testPercentEncodedUrlsMustNotBeDecoded() + throws Exception + { + PomTestWrapper pom = this.buildPom( "url-no-decoding" ); + assertEquals( "http://maven.apache.org/spacy%20path", pom.getValue( "url" ) ); + assertEquals( "http://svn.apache.org/viewvc/spacy%20path", pom.getValue( "scm/url" ) ); + assertEquals( "scm:svn:svn+ssh://svn.apache.org/spacy%20path", pom.getValue( "scm/connection" ) ); + assertEquals( "scm:svn:svn+ssh://svn.apache.org/spacy%20path", pom.getValue( "scm/developerConnection" ) ); + assertEquals( "http://issues.apache.org/spacy%20path", pom.getValue( "issueManagement/url" ) ); + assertEquals( "http://ci.apache.org/spacy%20path", pom.getValue( "ciManagement/url" ) ); + assertEquals( "scm:svn:svn+ssh://dist.apache.org/spacy%20path", + pom.getValue( "distributionManagement/repository/url" ) ); + assertEquals( "scm:svn:svn+ssh://snap.apache.org/spacy%20path", + pom.getValue( "distributionManagement/snapshotRepository/url" ) ); + assertEquals( "scm:svn:svn+ssh://site.apache.org/spacy%20path", + pom.getValue( "distributionManagement/site/url" ) ); + } + private void assertPathSuffixEquals( String expected, Object actual ) { String a = actual.toString(); diff --git a/maven-project/src/test/resources-project-builder/percent-encoded-url/pom.xml b/maven-project/src/test/resources-project-builder/percent-encoded-url/pom.xml deleted file mode 100644 index e683c0be88..0000000000 --- a/maven-project/src/test/resources-project-builder/percent-encoded-url/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its.mng4087 - test - 1.0-SNAPSHOT - jar - - Maven Integration Test :: MNG-4087 - - Test that deployment to a file:// repository decodes percent-encoded characters. - - - - - maven-core-it - - @baseurl@/target/%72%65%70%6F - - - - - - - org.apache.maven.its.plugins - maven-it-plugin-artifact - 2.1-SNAPSHOT - - pom.xml - - - - test - validate - - set - install - deploy - - - - - - - diff --git a/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml b/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml new file mode 100644 index 0000000000..5b92e23ed9 --- /dev/null +++ b/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4116 + test + 1.0-SNAPSHOT + jar + + Maven Integration Test :: MNG-4116 + + Test that the project builder does not decode URLs (which must be done by the transport layer instead). + + + + http://maven.apache.org/spacy%20path + + scm:svn:svn+ssh://svn.apache.org/spacy%20path + scm:svn:svn+ssh://svn.apache.org/spacy%20path + http://svn.apache.org/viewvc/spacy%20path + + + none + http://issues.apache.org/spacy%20path + + + none + http://ci.apache.org/spacy%20path + + + + dist + scm:svn:svn+ssh://dist.apache.org/spacy%20path + + + snap + scm:svn:svn+ssh://snap.apache.org/spacy%20path + + + site + scm:svn:svn+ssh://site.apache.org/spacy%20path + + +