This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.10 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git
commit 2b102be0fa17456eacadca389bfca79b9212bcc2 Author: Carsten Ziegeler <cziege...@apache.org> AuthorDate: Tue Nov 15 09:10:51 2011 +0000 SLING-2282 : Java Script Engine does not escape directory paths git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@1202102 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/scripting/java/impl/CompilerUtil.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java index 3dd271f..7b69572 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java @@ -30,11 +30,22 @@ public class CompilerUtil { } else { str = path; } - final int pos = str.lastIndexOf("/"); - if ( pos == -1 ) { - return makeJavaIdentifier(str); + final StringBuilder sb = new StringBuilder(); + int pos = 0; + int start = 0; + while ( pos < str.length() ) { + final char c = str.charAt(pos); + if ( c == '/' ) { + if ( start != pos ) { + sb.append(makeJavaIdentifier(str.substring(start, pos))); + } + sb.append(c); + start = pos + 1; + } + pos++; } - return str.substring(0, pos + 1) + makeJavaIdentifier(str.substring(pos + 1)); + sb.append(makeJavaIdentifier(str.substring(start))); + return sb.toString(); } /** -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.