Skip to content

Commit 9ac60ae

Browse files
Consistent handling of escape sequences in inline/wod constant bindings
1 parent 55531c8 commit 9ac60ae

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

ng-appserver/src/main/java/ng/appserver/templating/associations/NGAssociationFactory.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ private static NGAssociation associationForValue( String value, final boolean is
3939
}
4040

4141
// Inline value without $ prefix — constant string
42-
if( isQuoted ) {
43-
value = value.replace( "\\$", "$" ); // Unescape escaped dollar signs
44-
value = value.replace( "\\\"", "\"" ); // Unescape escaped quotes
45-
}
46-
4742
return associationForConstantStringValue( value );
4843
}
4944

@@ -120,7 +115,9 @@ private static NGAssociation associationForKeyPath( final String keyPath ) {
120115
}
121116

122117
/**
123-
* @return The given string with escape sequences \r, \n and \t converted to what they represent
118+
* @return The given string with escape sequences converted to what they represent.
119+
*
120+
* Supports: \n (newline), \r (carriage return), \t (tab), \\ (backslash), \" (quote), \$ (dollar sign)
124121
*/
125122
static String applyEscapes( String string ) {
126123

@@ -141,6 +138,8 @@ static String applyEscapes( String string ) {
141138
case 'r' -> sb.replace( i, i + 2, "\r" );
142139
case 't' -> sb.replace( i, i + 2, "\t" );
143140
case '\\' -> sb.replace( i, i + 2, "\\" );
141+
case '"' -> sb.replace( i, i + 2, "\"" );
142+
case '$' -> sb.replace( i, i + 2, "$" );
144143
default -> throw new IllegalArgumentException( "Unknown escape character: '%s' (%s) ".formatted( nextChar, Character.getName( nextChar ) ) );
145144
}
146145
}

0 commit comments

Comments
 (0)