Skip to content

Commit bad818e

Browse files
fix: the Quotes Token manipulation
- off now by one char at start Signed-off-by: Andreas Reichel <[email protected]>
1 parent 9d1442e commit bad818e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -738,22 +738,23 @@ TOKEN:
738738
// which contains the <SPECIAL_ESC>, then we will need to
739739
// 1) break the <S_CHAR_LITERAL> at <SPECIAL_ESC> close it with a "'"
740740
// 2) continue tokenizing after that <SPECIAL_ESC> with a new <S_CHAR_LITERAL> or any other Token
741-
if ( !configuration.getAsBoolean(Feature.allowBackslashEscapeCharacter) && matchedToken.image.contains("\\'") ) {
742-
matchedToken.image = image.substring( 0, image.indexOf("\\'") + 1 ) + "'";
741+
if ( !configuration.getAsBoolean(Feature.allowBackslashEscapeCharacter)
742+
&& matchedToken.image.contains("\\'") ) {
743+
matchedToken.image = "'" + image.substring( 0, image.indexOf("\\'") + 1 ) + "'";
743744
for (int i=0;i<CCJSqlParserConstants.tokenImage.length;i++) {
744745
if ( CCJSqlParserConstants.tokenImage[i].equals("<S_CHAR_LITERAL>") ) {
745746
matchedToken.kind = i;
746747
}
747748
}
748-
input_stream.backup(image.length() - matchedToken.image.length() );
749+
input_stream.backup(image.length() + 1 - matchedToken.image.length());
749750
} else if ( configuration.getAsBoolean(Feature.allowBackslashEscapeCharacter) && matchedToken.image.contains("\\''") ) {
750-
matchedToken.image = image.substring( 0, image.lastIndexOf("\\'") + 3);
751+
matchedToken.image = "'" + image.substring( 0, image.lastIndexOf("\\'") + 3);
751752
for (int i=0;i<CCJSqlParserConstants.tokenImage.length;i++) {
752753
if ( CCJSqlParserConstants.tokenImage[i].equals("<S_CHAR_LITERAL>") ) {
753754
matchedToken.kind = i;
754755
}
755756
}
756-
input_stream.backup(image.length() - matchedToken.image.length() );
757+
input_stream.backup(image.length() + 1 - matchedToken.image.length() );
757758
}
758759
}
759760
| < S_QUOTED_IDENTIFIER: "\"" ( "\"\"" | ~["\n","\r","\""])* "\"" | "$$" (~["$"])* "$$" | ("`" (~["\n","\r","`"])+ "`") | ( "[" (~["\n","\r","]"])* "]" ) >

0 commit comments

Comments
 (0)