You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2021/04/06 07:15:39 UTC

[santuario-xml-security-java] branch master updated: SANTUARIO-566 - Path.toUri().toString() result not supported on Windows

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/santuario-xml-security-java.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f53612  SANTUARIO-566 - Path.toUri().toString() result not supported on Windows
0f53612 is described below

commit 0f536120391a2370fca23f1c6a45fee1b2ec09e1
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Apr 6 08:14:53 2021 +0100

    SANTUARIO-566 - Path.toUri().toString() result not supported on Windows
---
 .../implementations/ResolverLocalFilesystem.java   | 41 +---------------------
 1 file changed, 1 insertion(+), 40 deletions(-)

diff --git a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
index 8a1ea66..8dc1548 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
@@ -34,8 +34,6 @@ import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
  */
 public class ResolverLocalFilesystem extends ResourceResolverSpi {
 
-    private static final int FILE_URI_LENGTH = "file:/".length();
-
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(ResolverLocalFilesystem.class);
 
@@ -49,9 +47,7 @@ public class ResolverLocalFilesystem extends ResourceResolverSpi {
             // calculate new URI
             URI uriNew = getNewURI(context.uriToResolve, context.baseUri);
 
-            String fileName =
-                ResolverLocalFilesystem.translateUriToFilename(uriNew.toString());
-            InputStream inputStream = Files.newInputStream(Paths.get(fileName));    //NOPMD
+            InputStream inputStream = Files.newInputStream(Paths.get(uriNew));  //NOPMD
             XMLSignatureInput result = new XMLSignatureInput(inputStream);
             result.setSecureValidation(context.secureValidation);
 
@@ -64,41 +60,6 @@ public class ResolverLocalFilesystem extends ResourceResolverSpi {
     }
 
     /**
-     * Method translateUriToFilename
-     *
-     * @param uri
-     * @return the string of the filename
-     */
-    private static String translateUriToFilename(String uri) {
-
-        String subStr = uri.substring(FILE_URI_LENGTH);
-
-        if (subStr.indexOf("%20") > -1) {
-            int offset = 0;
-            int index = 0;
-            StringBuilder temp = new StringBuilder(subStr.length());
-            do {
-                index = subStr.indexOf("%20",offset);
-                if (index == -1) {
-                    temp.append(subStr.substring(offset));
-                } else {
-                    temp.append(subStr.substring(offset, index));
-                    temp.append(' ');
-                    offset = index + 3;
-                }
-            } while(index != -1);
-            subStr = temp.toString();
-        }
-
-        if (subStr.charAt(1) == ':') {
-            // we're running M$ Windows, so this works fine
-            return subStr;
-        }
-        // we're running some UNIX, so we have to prepend a slash
-        return "/" + subStr;
-    }
-
-    /**
      * {@inheritDoc}
      */
     public boolean engineCanResolveURI(ResourceResolverContext context) {