You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2019/12/19 16:15:36 UTC
[sling-org-apache-sling-scripting-sightly] branch master updated:
SLING-8933 - The IncludeRuntimeExtension doesn't correctly normalise paths
when using the path manipulation options
This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly.git
The following commit(s) were added to refs/heads/master by this push:
new 5cd359b SLING-8933 - The IncludeRuntimeExtension doesn't correctly normalise paths when using the path manipulation options
5cd359b is described below
commit 5cd359b61d8ab97f22e47dfaf0e89161738c6f3c
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Thu Dec 19 17:15:06 2019 +0100
SLING-8933 - The IncludeRuntimeExtension doesn't correctly normalise paths when using the path manipulation options
* corrected path options handling in the IncludeRuntimeExtension
* updated to HTL TCK 1.4.1 which brings more tests for path options
---
.../engine/extension/IncludeRuntimeExtension.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
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 b79dadd..ff81686 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
@@ -28,6 +28,7 @@ import javax.servlet.Servlet;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.scripting.SlingScriptHelper;
import org.apache.sling.api.servlets.ServletResolver;
import org.apache.sling.scripting.sightly.SightlyException;
@@ -82,14 +83,24 @@ public class IncludeRuntimeExtension implements RuntimeExtension {
return null;
}
String prependPath = (String) options.get(OPTION_PREPEND_PATH);
- String appendPath = (String) options.get(OPTION_APPEND_PATH);
+ if (prependPath == null) {
+ prependPath = StringUtils.EMPTY;
+ }
if (StringUtils.isNotEmpty(prependPath)) {
- path = prependPath + path;
+ if (!prependPath.endsWith("/")) {
+ prependPath += "/";
+ }
+ }
+ String appendPath = (String) options.get(OPTION_APPEND_PATH);
+ if (appendPath == null) {
+ appendPath = StringUtils.EMPTY;
}
if (StringUtils.isNotEmpty(appendPath)) {
- path = path + appendPath;
+ if (!appendPath.startsWith("/")) {
+ appendPath = "/" + appendPath;
+ }
}
- return path;
+ return ResourceUtil.normalize(prependPath + path + appendPath);
}
private void includeScript(final Bindings bindings, String script, PrintWriter out) {