HHH-7973 - Fix String literals in an HQL query can get mangled

This commit is contained in:
Andrea Boriero 2016-02-05 21:15:05 +00:00
parent 9c75e79bc9
commit 57b32543ed
1 changed files with 20 additions and 0 deletions

View File

@ -90,6 +90,18 @@ public final class QuerySplitter {
templateQuery.append( token );
continue;
}
else if ( isTokenStartWithAQuoteCharacter( token ) ) {
if ( !isTokenEndWithAQuoteCharacter( token ) ) {
inQuote = true;
}
templateQuery.append( token );
continue;
}
else if ( isTokenEndWithAQuoteCharacter( token ) ) {
inQuote = false;
templateQuery.append( token );
continue;
}
else if ( inQuote ) {
templateQuery.append( token );
continue;
@ -131,6 +143,14 @@ public final class QuerySplitter {
return "'".equals( token ) || "\"".equals( token );
}
private static boolean isTokenStartWithAQuoteCharacter(String token) {
return token.startsWith( "'" ) || token.startsWith( "\"" );
}
private static boolean isTokenEndWithAQuoteCharacter(String token) {
return token.endsWith( "'" ) || token.endsWith( "\"" );
}
private static String nextNonWhite(String[] tokens, int start) {
for ( int i = start + 1; i < tokens.length; i++ ) {
if ( !ParserHelper.isWhitespace( tokens[i] ) ) {