This is an automated email from the ASF dual-hosted git repository. andysch pushed a commit to branch fix/SLING-11427-Namespace-with-hashtag in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-repoinit-parser.git
commit 9235c6d5718b4a3034f467d347207dcc903dbead Author: Andreas Schaefer <[email protected]> AuthorDate: Wed Jun 29 16:48:42 2022 -0700 Added a simple fix for the Hashtag in a Namespace --- .../apache/sling/repoinit/parser/operations/RegisterNamespace.java | 2 +- src/main/javacc/RepoInitGrammar.jjt | 6 +++--- src/test/resources/testcases/test-40-output.txt | 3 ++- src/test/resources/testcases/test-40.txt | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/sling/repoinit/parser/operations/RegisterNamespace.java b/src/main/java/org/apache/sling/repoinit/parser/operations/RegisterNamespace.java index 9ba2c99..369a4cc 100644 --- a/src/main/java/org/apache/sling/repoinit/parser/operations/RegisterNamespace.java +++ b/src/main/java/org/apache/sling/repoinit/parser/operations/RegisterNamespace.java @@ -39,7 +39,7 @@ public class RegisterNamespace extends Operation { protected String getParametersDescription() { final StringBuilder sb = new StringBuilder(); sb.append("(").append(prefix == null ? "" : prefix).append(") "); - sb.append(uri); + sb.append(uri.replaceAll("\\\\#", "#")); return sb.toString(); } diff --git a/src/main/javacc/RepoInitGrammar.jjt b/src/main/javacc/RepoInitGrammar.jjt index 8108ba9..b7abd4e 100644 --- a/src/main/javacc/RepoInitGrammar.jjt +++ b/src/main/javacc/RepoInitGrammar.jjt @@ -107,7 +107,7 @@ TOKEN: | < NAMESPACED_ITEM: (["a"-"z"] | ["A"-"Z"])+ ":" (["a"-"z"] | ["A"-"Z"])+ > | < PATH_STRING: "/" (["a"-"z"] | ["A"-"Z"] | ["0"-"9"] | ["-"] | ["_"] | ["."] | ["@"] | [":"] | ["+"] | ["/"]) * > | < PATH_REPOSITORY: ":repository" > -| < STRING: (["a"-"z"] | ["A"-"Z"] | ["0"-"9"] | ["-"] | ["_"] | ["."] | ["/"] | [":"] | ["*"]) + > +| < STRING: (["a"-"z"] | ["A"-"Z"] | ["0"-"9"] | ["-"] | ["_"] | ["."] | ["/"] | [":"] | ["*"] | "\\#") + > | < EOL: "\n" > } @@ -665,8 +665,8 @@ void registerNamespaceStatement(List<Operation> result) : } { <REGISTER> <NAMESPACE> - <LPAREN> prefix = <STRING> <RPAREN> - uri = <STRING> + <LPAREN> prefix = <STRING> <RPAREN> + uri = <STRING> { result.add(new RegisterNamespace(prefix.image, uri.image)); diff --git a/src/test/resources/testcases/test-40-output.txt b/src/test/resources/testcases/test-40-output.txt index 097e4bf..d4ad45f 100644 --- a/src/test/resources/testcases/test-40-output.txt +++ b/src/test/resources/testcases/test-40-output.txt @@ -1,2 +1,3 @@ RegisterNamespace (foo) uri:some-uri/V/1.0 -RegisterNamespace (prefix_with-other.things) andSimpleURI \ No newline at end of file +RegisterNamespace (prefix_with-other.things) andSimpleURI +RegisterNamespace (foo2) uri:some-uri/V/1.1/test# diff --git a/src/test/resources/testcases/test-40.txt b/src/test/resources/testcases/test-40.txt index f48ea04..290589f 100644 --- a/src/test/resources/testcases/test-40.txt +++ b/src/test/resources/testcases/test-40.txt @@ -2,4 +2,5 @@ # o.a.s.repoinit.parser 1.0.4 # and o.a.s.jcr.repoinit 1.0.2 register namespace (foo) uri:some-uri/V/1.0 -register namespace ( prefix_with-other.things ) andSimpleURI \ No newline at end of file +register namespace ( prefix_with-other.things ) andSimpleURI +register namespace (foo2) uri:some-uri/V/1.1/test\# \ No newline at end of file
