You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2024/06/28 15:04:35 UTC
(tomcat) branch 9.0.x updated: Refactor normalization to align with how Jasper does it elsewhere
This is an automated email from the ASF dual-hosted git repository.
markt 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 c7dcac8978 Refactor normalization to align with how Jasper does it elsewhere
c7dcac8978 is described below
commit c7dcac8978a80342f9331e703061a279106780ca
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 28 15:49:50 2024 +0100
Refactor normalization to align with how Jasper does it elsewhere
I did look at pulling this code into a common utility function but the
usage is just different enough that it isn't (yet) worth it.
---
java/org/apache/jasper/compiler/ParserController.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/jasper/compiler/ParserController.java b/java/org/apache/jasper/compiler/ParserController.java
index 2d89348a1e..05b38e0bed 100644
--- a/java/org/apache/jasper/compiler/ParserController.java
+++ b/java/org/apache/jasper/compiler/ParserController.java
@@ -20,7 +20,8 @@ import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.nio.file.Paths;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayDeque;
import java.util.Deque;
@@ -198,7 +199,12 @@ class ParserController implements TagConstants {
boolean processingTagInJar = jar != null && baseDirStack.peekFirst() != null &&
baseDirStack.peekFirst().startsWith(TAGS_IN_JAR_LOCATION);
- String absFileName = resolveFileName(inFileName);
+ String absFileName = null;
+ try {
+ absFileName = resolveFileName(inFileName);
+ } catch (URISyntaxException e) {
+ err.jspError("jsp.error.invalid.includeInTagFileJar", inFileName, jar.getJarFileURL().toString());
+ }
if (processingTagInJar && !absFileName.startsWith(TAGS_IN_JAR_LOCATION)) {
/*
* An included file is being parsed that was included from the standard location for tag files in JAR but
@@ -529,11 +535,12 @@ class ParserController implements TagConstants {
* The 'root' file is always an 'absolute' path, so no need to put an
* initial value in the baseDirStack.
*/
- private String resolveFileName(String inFileName) {
+ private String resolveFileName(String inFileName) throws URISyntaxException {
String fileName = inFileName.replace('\\', '/');
boolean isAbsolute = fileName.startsWith("/");
if (!isAbsolute) {
- fileName = Paths.get(baseDirStack.peekFirst() + fileName).normalize().toString().replace('\\', '/');
+ URI uri = new URI(baseDirStack.peekFirst() + fileName);
+ fileName = uri.normalize().toString();
}
String baseDir = fileName.substring(0, fileName.lastIndexOf('/') + 1);
baseDirStack.addFirst(baseDir);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org