maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r759729 - in /maven/components/trunk: maven-project-builder/src/main/java/org/apache/maven/project/processor/ maven-project/src/test/java/org/apache/maven/project/ maven-project/src/test/resources-project-builder/percent-encoded-url/ maven-...
Date Sun, 29 Mar 2009 17:18:40 GMT
Author: bentmann
Date: Sun Mar 29 17:18:39 2009
New Revision: 759729

URL: http://svn.apache.org/viewvc?rev=759729&view=rev
Log:
[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)

Added:
    maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/
  (with props)
    maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml
  (with props)
Removed:
    maven/components/trunk/maven-project/src/test/resources-project-builder/percent-encoded-url/
Modified:
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java?rev=759729&r1=759728&r2=759729&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/BaseProcessor.java
Sun Mar 29 17:18:39 2009
@@ -20,11 +20,8 @@
  */
 
 
-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 @@
         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 @@
 			{
 				normalized = normalized.replaceFirst("/", slashes);
 			}
-			return decodeUrl(normalized);   
+			return normalized;   
 		} 
 		catch (URISyntaxException e) {
 
@@ -164,7 +146,7 @@
 		List<String> modules = moduleProject.getModules();
 		if (modules != null) {
 			for (Iterator<String> it = modules.iterator(); it.hasNext();) {
-				String modulePath = (String) it.next();
+				String modulePath = it.next();
 				String moduleName = modulePath;
 
 				if (moduleName.endsWith("/") || moduleName.endsWith("\\")) {

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java?rev=759729&r1=759728&r2=759729&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/DistributionManagementProcessor.java
Sun Mar 29 17:18:39 2009
@@ -19,10 +19,6 @@
  * 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 @@
 
         if ( target.getUrl() == null )
         {
-        	target.setUrl( decodeUrl(source.getUrl()) );
+        	target.setUrl( source.getUrl() );
         }
 
         if ( target.getName() == null )
@@ -151,7 +147,7 @@
         {
             if ( isChild )
             {
-                target.setUrl( decodeUrl(source.getUrl()) );
+                target.setUrl( source.getUrl() );
             }         
             else
             {          	
@@ -160,7 +156,7 @@
         }
         else 
         {
-            target.setUrl( decodeUrl(target.getUrl() + (target.getUrl().endsWith("/")  ?
"" : "/")+ artifactId) );
+            target.setUrl( target.getUrl() + (target.getUrl().endsWith("/")  ? "" : "/")+
artifactId );
         }
     }
 

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java?rev=759729&r1=759728&r2=759729&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ModelProcessor.java
Sun Mar 29 17:18:39 2009
@@ -19,7 +19,6 @@
  * under the License.
  */
 
-import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -124,7 +123,7 @@
         
         if ( c.getUrl() != null )
         {
-            t.setUrl(decodeUrl(c.getUrl()));         
+            t.setUrl( c.getUrl() );         
         }       
         else if(p != null && p.getUrl() != null)
         {        	
@@ -132,7 +131,7 @@
         }
         else if (t.getUrl() != null)
         {
-            t.setUrl( decodeUrl(t.getUrl() + "/" + t.getArtifactId()) );
+            t.setUrl( t.getUrl() + "/" + t.getArtifactId() );
         }
         
         //Dependencies

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java?rev=759729&r1=759728&r2=759729&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/processor/ScmProcessor.java
Sun Mar 29 17:18:39 2009
@@ -19,10 +19,6 @@
  * 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 @@
     {
         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 @@
     {
         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 @@
     {
         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 );
         }           
     }    
     

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=759729&r1=759728&r2=759729&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
(original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java
Sun Mar 29 17:18:39 2009
@@ -768,7 +768,7 @@
         testAppendOfInheritedPluginConfiguration( "no-profile" );
     }
     
-    /* FIXME: MNG-2591*/
+    /* MNG-2591*/
     public void testAppendOfInheritedPluginConfigurationWithActiveProfile()
         throws Exception
     {
@@ -928,15 +928,7 @@
         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 @@
         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();

Propchange: maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/
------------------------------------------------------------------------------
    bugtraq:label = Enter issue ID:

Propchange: maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/
------------------------------------------------------------------------------
    bugtraq:message = Issue id: %BUGID%

Propchange: maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/
------------------------------------------------------------------------------
    bugtraq:number = false

Propchange: maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml?rev=759729&view=auto
==============================================================================
--- maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml
(added)
+++ maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml
Sun Mar 29 17:18:39 2009
@@ -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>

Propchange: maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-project/src/test/resources-project-builder/url-no-decoding/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message