This is an automated email from the ASF dual-hosted git repository. jbonofre pushed a commit to branch karaf-4.3.x in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.3.x by this push: new acf0340 Support spaces in boot features path acf0340 is described below commit acf0340f42b990e749c22a872fa07ae7560c6c83 Author: Donnie McMahan <mcmaha...@pella.com> AuthorDate: Wed Jan 5 15:38:37 2022 -0600 Support spaces in boot features path (cherry picked from commit 5e5a996682d33dfdabafcece1a971ff26c438cdf) --- .../internal/service/BootFeaturesInstaller.java | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java index 5f0db17..b288e91 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java @@ -16,22 +16,16 @@ */ package org.apache.karaf.features.internal.service; -import java.io.File; -import java.net.URI; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.Hashtable; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.StringTokenizer; - import org.apache.karaf.features.BootFinished; import org.apache.karaf.features.FeaturesService; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.net.URI; +import java.util.*; + public class BootFeaturesInstaller { private static final Logger LOGGER = LoggerFactory.getLogger(BootFeaturesInstaller.class); @@ -119,6 +113,7 @@ public class BootFeaturesInstaller { repo = repo.trim(); if (!repo.isEmpty()) { repo = separatorsToUnix(repo); + repo = encodePath(repo); try { featuresService.addRepository(URI.create(repo)); } catch (Exception e) { @@ -192,4 +187,18 @@ public class BootFeaturesInstaller { } return path; } + + /** + * Converts all invalid characters in a path to a format supported by {@link URI#create(String)}. + * + * @param path the path to encode, null ignored + * @return the encoded path + */ + private String encodePath(String path) { + if (path == null) { + return null; + } + + return path.replace(" ", "%20"); + } }