SLING-8933 - The IncludeRuntimeExtension doesn't correctly normalise paths when using the path manipulation options
* let Sling do the path normalisation when resolving the servlet relative to the current script resource
diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java
index ff81686..6bdc644 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java
@@ -87,7 +87,7 @@
prependPath = StringUtils.EMPTY;
}
if (StringUtils.isNotEmpty(prependPath)) {
- if (!prependPath.endsWith("/")) {
+ if (!prependPath.endsWith("/") && !path.startsWith("/")) {
prependPath += "/";
}
}
@@ -96,11 +96,11 @@
appendPath = StringUtils.EMPTY;
}
if (StringUtils.isNotEmpty(appendPath)) {
- if (!appendPath.startsWith("/")) {
+ if (!appendPath.startsWith("/") && !path.endsWith("/")) {
appendPath = "/" + appendPath;
}
}
- return ResourceUtil.normalize(prependPath + path + appendPath);
+ return prependPath + path + appendPath;
}
private void includeScript(final Bindings bindings, String script, PrintWriter out) {