SLING-9227 - remove escaping backslash in quoted string
diff --git a/src/main/javacc/RepoInitGrammar.jjt b/src/main/javacc/RepoInitGrammar.jjt
index 8ece527..a6bbb73 100644
--- a/src/main/javacc/RepoInitGrammar.jjt
+++ b/src/main/javacc/RepoInitGrammar.jjt
@@ -654,17 +654,29 @@
}
}
+String quotedString() :
+{
+ Token str = null;
+}
+{
+ ( str = <QUOTED> )
+ {
+ // Remove escaping backslash for double quotes
+ return str.image.replaceAll("\\\\\"", "\"");
+ }
+}
+
void disableServiceUserStatement(List<Operation> result) :
{
Token user = null;
- Token msg = null;
+ String msg = null;
}
{
<DISABLE> <SERVICE> <USER>
( user = <STRING> )
- ( <COLON> msg = <QUOTED> )
+ ( <COLON> msg = quotedString() )
{
- result.add(new DisableServiceUser(user.image, msg == null ? null : msg.image));
+ result.add(new DisableServiceUser(user.image, msg));
}
}
diff --git a/src/test/java/org/apache/sling/repoinit/parser/test/ParsingErrorsTest.java b/src/test/java/org/apache/sling/repoinit/parser/test/ParsingErrorsTest.java
index ddbf056..c5c5628 100644
--- a/src/test/java/org/apache/sling/repoinit/parser/test/ParsingErrorsTest.java
+++ b/src/test/java/org/apache/sling/repoinit/parser/test/ParsingErrorsTest.java
@@ -70,6 +70,7 @@
add(new Object[] { "disable service user foo", ParseException.class });
// Quoted strings in disable service user
+ add(new Object[] { "disable service user foo", ParseException.class });
add(new Object[] { "disable service user foo missing colon and quotes", ParseException.class });
add(new Object[] { "disable service user foo : missing quotes", ParseException.class });
add(new Object[] { "disable service user foo \"missing colon\"", ParseException.class });
diff --git a/src/test/resources/testcases/test-61-output.txt b/src/test/resources/testcases/test-61-output.txt
index 912251c..4375388 100644
--- a/src/test/resources/testcases/test-61-output.txt
+++ b/src/test/resources/testcases/test-61-output.txt
@@ -1 +1,2 @@
-DisableServiceUser svcA : This message explains why it's disabled. Whitespace is preserved.
\ No newline at end of file
+DisableServiceUser svcA : This message explains why it's disabled. Whitespace is preserved.
+DisableServiceUser svcB : Testing escaped double "quote" in this string.
\ No newline at end of file
diff --git a/src/test/resources/testcases/test-61.txt b/src/test/resources/testcases/test-61.txt
index 669fba9..72b2324 100644
--- a/src/test/resources/testcases/test-61.txt
+++ b/src/test/resources/testcases/test-61.txt
@@ -1,2 +1,3 @@
# Test "disable service user" statements
-disable service user svcA : "This message explains why it's disabled. Whitespace is preserved."
\ No newline at end of file
+disable service user svcA : "This message explains why it's disabled. Whitespace is preserved."
+disable service user svcB : "Testing escaped double \"quote\" in this string."
\ No newline at end of file