mirror of https://github.com/apache/maven.git
[MNG-4116] [regression] Effective POM contains invalid URLs upon usage of percent-encoded characters
o Fixed by reverting r759364 (the issue meant to be fixed was a Wagon issue, not a POM issue) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@759729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bd263f7da7
commit
136bac419e
|
@ -20,11 +20,8 @@ package org.apache.maven.project.processor;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -100,21 +97,6 @@ public abstract class BaseProcessor implements Processor
|
||||||
return parent;
|
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)
|
protected String normalizeUriWithRelativePath(String u, String artifactId, Model parent)
|
||||||
{
|
{
|
||||||
if(u == null)
|
if(u == null)
|
||||||
|
@ -132,7 +114,7 @@ public abstract class BaseProcessor implements Processor
|
||||||
{
|
{
|
||||||
normalized = normalized.replaceFirst("/", slashes);
|
normalized = normalized.replaceFirst("/", slashes);
|
||||||
}
|
}
|
||||||
return decodeUrl(normalized);
|
return normalized;
|
||||||
}
|
}
|
||||||
catch (URISyntaxException e) {
|
catch (URISyntaxException e) {
|
||||||
|
|
||||||
|
@ -164,7 +146,7 @@ public abstract class BaseProcessor implements Processor
|
||||||
List<String> modules = moduleProject.getModules();
|
List<String> modules = moduleProject.getModules();
|
||||||
if (modules != null) {
|
if (modules != null) {
|
||||||
for (Iterator<String> it = modules.iterator(); it.hasNext();) {
|
for (Iterator<String> it = modules.iterator(); it.hasNext();) {
|
||||||
String modulePath = (String) it.next();
|
String modulePath = it.next();
|
||||||
String moduleName = modulePath;
|
String moduleName = modulePath;
|
||||||
|
|
||||||
if (moduleName.endsWith("/") || moduleName.endsWith("\\")) {
|
if (moduleName.endsWith("/") || moduleName.endsWith("\\")) {
|
||||||
|
|
|
@ -19,10 +19,6 @@ package org.apache.maven.project.processor;
|
||||||
* under the License.
|
* 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.DeploymentRepository;
|
||||||
import org.apache.maven.model.DistributionManagement;
|
import org.apache.maven.model.DistributionManagement;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
|
@ -124,7 +120,7 @@ public class DistributionManagementProcessor
|
||||||
|
|
||||||
if ( target.getUrl() == null )
|
if ( target.getUrl() == null )
|
||||||
{
|
{
|
||||||
target.setUrl( decodeUrl(source.getUrl()) );
|
target.setUrl( source.getUrl() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( target.getName() == null )
|
if ( target.getName() == null )
|
||||||
|
@ -151,7 +147,7 @@ public class DistributionManagementProcessor
|
||||||
{
|
{
|
||||||
if ( isChild )
|
if ( isChild )
|
||||||
{
|
{
|
||||||
target.setUrl( decodeUrl(source.getUrl()) );
|
target.setUrl( source.getUrl() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -160,7 +156,7 @@ public class DistributionManagementProcessor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
target.setUrl( decodeUrl(target.getUrl() + (target.getUrl().endsWith("/") ? "" : "/")+ artifactId) );
|
target.setUrl( target.getUrl() + (target.getUrl().endsWith("/") ? "" : "/")+ artifactId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.project.processor;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -124,7 +123,7 @@ public class ModelProcessor
|
||||||
|
|
||||||
if ( c.getUrl() != null )
|
if ( c.getUrl() != null )
|
||||||
{
|
{
|
||||||
t.setUrl(decodeUrl(c.getUrl()));
|
t.setUrl( c.getUrl() );
|
||||||
}
|
}
|
||||||
else if(p != null && p.getUrl() != null)
|
else if(p != null && p.getUrl() != null)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +131,7 @@ public class ModelProcessor
|
||||||
}
|
}
|
||||||
else if (t.getUrl() != null)
|
else if (t.getUrl() != null)
|
||||||
{
|
{
|
||||||
t.setUrl( decodeUrl(t.getUrl() + "/" + t.getArtifactId()) );
|
t.setUrl( t.getUrl() + "/" + t.getArtifactId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dependencies
|
//Dependencies
|
||||||
|
|
|
@ -19,10 +19,6 @@ package org.apache.maven.project.processor;
|
||||||
* under the License.
|
* 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.Model;
|
||||||
import org.apache.maven.model.Scm;
|
import org.apache.maven.model.Scm;
|
||||||
|
|
||||||
|
@ -55,14 +51,14 @@ public class ScmProcessor extends BaseProcessor
|
||||||
{
|
{
|
||||||
if(c != null && c.getUrl() != null)
|
if(c != null && c.getUrl() != null)
|
||||||
{
|
{
|
||||||
t.setUrl(decodeUrl(c.getUrl()) );
|
t.setUrl( c.getUrl() );
|
||||||
}
|
}
|
||||||
else if(p != null && p.getUrl() != null)
|
else if(p != null && p.getUrl() != null)
|
||||||
{
|
{
|
||||||
t.setUrl( normalizeUriWithRelativePath(p.getUrl(), artifactId, parent));
|
t.setUrl( normalizeUriWithRelativePath(p.getUrl(), artifactId, parent));
|
||||||
}
|
}
|
||||||
else if(t.getUrl() != null) {
|
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)
|
if(c!= null && c.getConnection() != null)
|
||||||
{
|
{
|
||||||
t.setConnection(decodeUrl(c.getConnection()));
|
t.setConnection( c.getConnection() );
|
||||||
}
|
}
|
||||||
else if(p != null && p.getConnection() != null)
|
else if(p != null && p.getConnection() != null)
|
||||||
{
|
{
|
||||||
t.setConnection( normalizeUriWithRelativePath(p.getConnection(), artifactId, parent));
|
t.setConnection( normalizeUriWithRelativePath(p.getConnection(), artifactId, parent));
|
||||||
}
|
}
|
||||||
else if(t.getConnection() != null) {
|
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)
|
if(c!= null && c.getDeveloperConnection() != null)
|
||||||
{
|
{
|
||||||
t.setDeveloperConnection(decodeUrl(c.getDeveloperConnection()));
|
t.setDeveloperConnection( c.getDeveloperConnection() );
|
||||||
}
|
}
|
||||||
else if(p != null && p.getDeveloperConnection() != null)
|
else if(p != null && p.getDeveloperConnection() != null)
|
||||||
{
|
{
|
||||||
t.setDeveloperConnection( normalizeUriWithRelativePath(p.getDeveloperConnection(), artifactId, parent) );
|
t.setDeveloperConnection( normalizeUriWithRelativePath(p.getDeveloperConnection(), artifactId, parent) );
|
||||||
}
|
}
|
||||||
else if(t.getDeveloperConnection() != null){
|
else if(t.getDeveloperConnection() != null){
|
||||||
t.setDeveloperConnection( decodeUrl(t.getDeveloperConnection() + "/" + artifactId) );
|
t.setDeveloperConnection( t.getDeveloperConnection() + "/" + artifactId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -768,7 +768,7 @@ public class PomConstructionTest
|
||||||
testAppendOfInheritedPluginConfiguration( "no-profile" );
|
testAppendOfInheritedPluginConfiguration( "no-profile" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: MNG-2591*/
|
/* MNG-2591*/
|
||||||
public void testAppendOfInheritedPluginConfigurationWithActiveProfile()
|
public void testAppendOfInheritedPluginConfigurationWithActiveProfile()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -929,14 +929,6 @@ public class PomConstructionTest
|
||||||
assertEquals("http://site.project.url/child", pom.getValue( "distributionManagement/site/url" ));
|
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 */
|
/** MNG-0479 */
|
||||||
public void testRepoInheritance()
|
public void testRepoInheritance()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
@ -1302,6 +1294,25 @@ public class PomConstructionTest
|
||||||
assertEquals("c", pom.getValue( "build/extensions[3]/artifactId" ) );
|
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 )
|
private void assertPathSuffixEquals( String expected, Object actual )
|
||||||
{
|
{
|
||||||
String a = actual.toString();
|
String a = actual.toString();
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
or more contributor license agreements. See the NOTICE file
|
|
||||||
distributed with this work for additional information
|
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
|
||||||
software distributed under the License is distributed on an
|
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied. See the License for the
|
|
||||||
specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>org.apache.maven.its.mng4087</groupId>
|
|
||||||
<artifactId>test</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>Maven Integration Test :: MNG-4087</name>
|
|
||||||
<description>
|
|
||||||
Test that deployment to a file:// repository decodes percent-encoded characters.
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>maven-core-it</id>
|
|
||||||
<!-- NOTE: The last URL part is intentionally percent-encoded and should be decoded to "repo" -->
|
|
||||||
<url>@baseurl@/target/%72%65%70%6F</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.its.plugins</groupId>
|
|
||||||
<artifactId>maven-it-plugin-artifact</artifactId>
|
|
||||||
<version>2.1-SNAPSHOT</version>
|
|
||||||
<configuration>
|
|
||||||
<mainFile>pom.xml</mainFile>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>test</id>
|
|
||||||
<phase>validate</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>set</goal>
|
|
||||||
<goal>install</goal>
|
|
||||||
<goal>deploy</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.apache.maven.its.mng4116</groupId>
|
||||||
|
<artifactId>test</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>Maven Integration Test :: MNG-4116</name>
|
||||||
|
<description>
|
||||||
|
Test that the project builder does not decode URLs (which must be done by the transport layer instead).
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<!-- some URLs using percent-encoded characters -->
|
||||||
|
<url>http://maven.apache.org/spacy%20path</url>
|
||||||
|
<scm>
|
||||||
|
<connection>scm:svn:svn+ssh://svn.apache.org/spacy%20path</connection>
|
||||||
|
<developerConnection>scm:svn:svn+ssh://svn.apache.org/spacy%20path</developerConnection>
|
||||||
|
<url>http://svn.apache.org/viewvc/spacy%20path</url>
|
||||||
|
</scm>
|
||||||
|
<issueManagement>
|
||||||
|
<system>none</system>
|
||||||
|
<url>http://issues.apache.org/spacy%20path</url>
|
||||||
|
</issueManagement>
|
||||||
|
<ciManagement>
|
||||||
|
<system>none</system>
|
||||||
|
<url>http://ci.apache.org/spacy%20path</url>
|
||||||
|
</ciManagement>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>dist</id>
|
||||||
|
<url>scm:svn:svn+ssh://dist.apache.org/spacy%20path</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>snap</id>
|
||||||
|
<url>scm:svn:svn+ssh://snap.apache.org/spacy%20path</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
<site>
|
||||||
|
<id>site</id>
|
||||||
|
<url>scm:svn:svn+ssh://site.apache.org/spacy%20path</url>
|
||||||
|
</site>
|
||||||
|
</distributionManagement>
|
||||||
|
</project>
|
Loading…
Reference in New Issue