This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new f9f96f385b Refactor normalization to align with how Jasper does it
elsewhere
f9f96f385b is described below
commit f9f96f385be9a08ef601528a89afd5f44755becf
Author: Mark Thomas <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]