This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 7e6bf491b0 Previous hack attempt would fail on Windows
7e6bf491b0 is described below
commit 7e6bf491b02630dd686017a0b775246ed2339401
Author: remm <[email protected]>
AuthorDate: Tue Jun 30 15:10:05 2026 +0200
Previous hack attempt would fail on Windows
Instead use a little bit of code from UriUtil, which has to be
duplicated since it is not available from here.
---
.../catalina/startup/CatalinaProperties.java | 37 +++++++++++++++++++---
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/catalina/startup/CatalinaProperties.java
b/java/org/apache/catalina/startup/CatalinaProperties.java
index ef96a4a85e..3119f1dd58 100644
--- a/java/org/apache/catalina/startup/CatalinaProperties.java
+++ b/java/org/apache/catalina/startup/CatalinaProperties.java
@@ -72,11 +72,12 @@ public class CatalinaProperties {
try {
String configUrl = System.getProperty("catalina.config");
if (configUrl != null) {
- if (configUrl.indexOf(':') == -1) {
- // No ':'. Must be a file name rather than a URL
- fileName = configUrl;
- } else {
+ boolean isAbsoluteUri = isAbsoluteURI(configUrl);
+ if (isAbsoluteUri) {
is = new URI(configUrl).toURL().openStream();
+ } else {
+ // Not an absolute URI. Must be a file name.
+ fileName = configUrl;
}
}
} catch (Throwable t) {
@@ -137,6 +138,34 @@ public class CatalinaProperties {
}
+ private static boolean isSchemeChar(char c) {
+ return Character.isLetterOrDigit(c) || c == '+' || c == '-' || c ==
'.';
+ }
+
+
+ private static boolean isAbsoluteURI(String path) {
+ // Special case as only a single /
+ if (path.startsWith("file:/")) {
+ return true;
+ }
+
+ // Start at the beginning of the path and skip over any valid protocol
+ // characters
+ int i = 0;
+ while (i < path.length() && isSchemeChar(path.charAt(i))) {
+ i++;
+ }
+ // Need at least one protocol character. False positives with Windows
+ // drives such as C:/... will be caught by the later test for "://"
+ if (i == 0) {
+ return false;
+ }
+ // path starts with something that might be a protocol. Look for a
+ // following "://"
+ return i + 2 < path.length() && path.charAt(i++) == ':' &&
path.charAt(i++) == '/' && path.charAt(i) == '/';
+ }
+
+
// Copied from ExceptionUtils since that class is not visible during start
private static void handleThrowable(Throwable t) {
if (t instanceof VirtualMachineError) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]