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

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 2e58ae8  Use URI filtering in the default source implementation
2e58ae8 is described below

commit 2e58ae8372f9e0e588681daa2a61cb7ad1e2500e
Author: remm <r...@apache.org>
AuthorDate: Fri Jan 29 15:13:50 2021 +0100

    Use URI filtering in the default source implementation
    
    Not actually used except in the testsuite, so no real change.
---
 .../tomcat/util/file/ConfigurationSource.java      | 34 +++++++++++++---------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/tomcat/util/file/ConfigurationSource.java 
b/java/org/apache/tomcat/util/file/ConfigurationSource.java
index 57d5ce4..4dec49a 100644
--- a/java/org/apache/tomcat/util/file/ConfigurationSource.java
+++ b/java/org/apache/tomcat/util/file/ConfigurationSource.java
@@ -26,6 +26,8 @@ import java.net.URI;
 import java.net.URL;
 import java.net.URLConnection;
 
+import org.apache.tomcat.util.buf.UriUtil;
+
 /**
  * Abstracts configuration file storage. Allows Tomcat embedding using the 
regular
  * configuration style.
@@ -40,17 +42,19 @@ public interface ConfigurationSource {
         protected final URI userDirUri = userDir.toURI();
         @Override
         public Resource getResource(String name) throws IOException {
-            File f = new File(name);
-            if (!f.isAbsolute()) {
-                f = new File(userDir, name);
-            }
-            if (f.isFile()) {
-                FileInputStream fis = new FileInputStream(f);
-                return new Resource(fis, f.toURI());
+            if (!UriUtil.isAbsoluteURI(name)) {
+                File f = new File(name);
+                if (!f.isAbsolute()) {
+                    f = new File(userDir, name);
+                }
+                if (f.isFile()) {
+                    FileInputStream fis = new FileInputStream(f);
+                    return new Resource(fis, f.toURI());
+                }
             }
             URI uri = null;
             try {
-                uri = getURI(name);
+                uri = userDirUri.resolve(name);
             } catch (IllegalArgumentException e) {
                 throw new FileNotFoundException(name);
             }
@@ -63,12 +67,14 @@ public interface ConfigurationSource {
         }
         @Override
         public URI getURI(String name) {
-            File f = new File(name);
-            if (!f.isAbsolute()) {
-                f = new File(userDir, name);
-            }
-            if (f.isFile()) {
-                return f.toURI();
+            if (!UriUtil.isAbsoluteURI(name)) {
+                File f = new File(name);
+                if (!f.isAbsolute()) {
+                    f = new File(userDir, name);
+                }
+                if (f.isFile()) {
+                    return f.toURI();
+                }
             }
             return userDirUri.resolve(name);
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to