From e7f7e70992d361d8b7a3298ddcdf49dda2fdc842 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 14 Mar 2023 12:33:58 +1000 Subject: [PATCH] fix tomcat:run with last log4j api and multi release jars Signed-off-by: Olivier Lamy --- .../web/api/DefaultFileUploadService.java | 17 ++- .../archiva/upload/UploadArtifactsTest.java | 5 +- .../archiva-web/archiva-webapp/pom.xml | 109 ++++++++++++++++++ 3 files changed, 124 insertions(+), 7 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java index 71199866c..83b3a3e6f 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java @@ -50,6 +50,7 @@ import org.apache.archiva.xml.XMLException; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; import org.apache.cxf.jaxrs.ext.multipart.Attachment; @@ -279,11 +280,11 @@ public class DefaultFileUploadService boolean generatePom ) throws ArchivaRestServiceException { - repositoryId = StringUtils.trim( repositoryId ); - groupId = StringUtils.trim( groupId ); - artifactId = StringUtils.trim( artifactId ); - version = StringUtils.trim( version ); - packaging = StringUtils.trim( packaging ); + repositoryId = StringEscapeUtils.escapeJavaScript( StringUtils.trim( repositoryId ) ); + groupId = StringEscapeUtils.escapeJavaScript( StringUtils.trim( groupId ) ); + artifactId = StringEscapeUtils.escapeJavaScript( StringUtils.trim( artifactId ) ); + version = StringEscapeUtils.escapeJavaScript( StringUtils.trim( version ) ); + packaging = StringEscapeUtils.escapeJavaScript( StringUtils.trim( packaging ) ); checkParamChars("repositoryId", repositoryId); checkParamChars("groupId", groupId); @@ -377,6 +378,12 @@ public class DefaultFileUploadService ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repositoryId ); + repositoryId = StringEscapeUtils.escapeJavaScript( StringUtils.trim( repositoryId ) ); + groupId = StringEscapeUtils.escapeJavaScript( StringUtils.trim( groupId ) ); + artifactId = StringEscapeUtils.escapeJavaScript( StringUtils.trim( artifactId ) ); + version = StringEscapeUtils.escapeJavaScript( StringUtils.trim( version ) ); + packaging = StringEscapeUtils.escapeJavaScript( StringUtils.trim( packaging ) ); + ArtifactReference artifactReference = new ArtifactReference(); artifactReference.setArtifactId( artifactId ); artifactReference.setGroupId( groupId ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/upload/UploadArtifactsTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/upload/UploadArtifactsTest.java index f3d82cf97..e15cb6a7b 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/upload/UploadArtifactsTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/upload/UploadArtifactsTest.java @@ -28,7 +28,6 @@ import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.apache.archiva.web.api.FileUploadService; import org.apache.archiva.web.model.FileMetadata; import org.apache.catalina.Context; -import org.apache.catalina.LifecycleException; import org.apache.catalina.deploy.ApplicationParameter; import org.apache.catalina.startup.Tomcat; import org.apache.commons.io.FileUtils; @@ -337,7 +336,9 @@ public class UploadArtifactsTest meta = service.post( body ); log.debug( "Metadata {}", meta.toString( ) ); try { - service.save("internal", "org", URLEncoder.encode("../../../test", "UTF-8"), URLEncoder.encode("testSave", "UTF-8"), "4", true); + service.save("internal", "org", + URLEncoder.encode("../../../test", "UTF-8"), + URLEncoder.encode("testSave", "UTF-8"), "4", true); fail("Error expected, if the content contains bad characters."); } catch (ClientErrorException e) { assertEquals(422, e.getResponse().getStatus()); diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index effe7b9d8..da9b48c98 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -45,6 +45,7 @@ jcr localhost 9160 + 7.0.76 @@ -852,6 +853,7 @@ ${archiva.sirona.configuration} Block Block + log4j-*.jar ${basedir}/src/test/tomcat @@ -868,6 +870,113 @@ mail ${javaxMailVersion} + + + org.apache.tomcat.embed + tomcat-embed-core + ${tomcat7Version} + + + org.apache.tomcat + tomcat-util + ${tomcat7Version} + + + org.apache.tomcat + tomcat-coyote + ${tomcat7Version} + + + org.apache.tomcat + tomcat-api + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-jdbc + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-dbcp + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-servlet-api + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-jsp-api + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-jasper + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-jasper-el + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-el-api + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-catalina + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-tribes + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-catalina-ha + ${tomcat7Version} + + + + org.apache.tomcat + tomcat-annotations-api + ${tomcat7Version} + + + + + + + org.apache.tomcat + tomcat-juli + ${tomcat7Version} + + + + org.apache.tomcat.embed + tomcat-embed-logging-juli + ${tomcat7Version} + + + org.apache.tomcat.embed + tomcat-embed-logging-log4j + ${tomcat7Version} + -- 2.39.5