Skip to content

Commit

Permalink
[21] Processed string templates falsely contain backslash characters
Browse files Browse the repository at this point in the history
  • Loading branch information
jarthana committed Dec 12, 2023
1 parent f8dddad commit 0d4afb0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10031,7 +10031,6 @@ protected void consumeTemplate(int token) {
}
// get rid of all the cached values
this.scanner.withoutUnicodePtr = 0;
this.scanner.textBlockOffset = -1;
StringTemplate template = new StringTemplate(fragments, expressions, fragments[0].sourceStart, fragments[expressions.length].sourceEnd, isMultiline);
pushOnExpressionStack(template);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,7 @@ protected int scanForStringLiteral() throws InvalidInputException {
this.startPosition = startBkup;
return token;
} else {
this.textBlockOffset = -1; // Make sure that the previous values set by any preceding text block is reset.
int textFragmentStart = this.currentPosition - 1;
int lastCharPos = this.currentPosition;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1756,4 +1756,43 @@ interface Intf {
"Syntax error on token \")\", delete this token\n" +
"----------\n");
}
public void testIssue1719() {
runConformTest(
new String[] {
"X.java",
"""
public class X {
public static void main(String[] args) {
String name = "Bill";
System.out.println(STR."\\{name}");
String html = STR.\"""
\\{name}
\""";
}
}"""
},
"Bill");
}
public void testIssue1722() {
runConformTest(
new String[] {
"X.java",
"""
public class X {
public static void main(String[] args) {
String firstName = "Bill", lastName = "Duck";
System.out.println(STR."\\{firstName} \\{lastName}");
String title = "My Web Page";
String html = STR.\"""
</head>
\""";
System.out.println(html);
}
}"""
},
"Bill Duck\n" +
" </head>");
}
}

0 comments on commit 0d4afb0

Please sign in to comment.