Skip to content

Commit

Permalink
Fixed CORE-6340 - Alternate quoting does not work on some particular …
Browse files Browse the repository at this point in the history
…cases.
  • Loading branch information
asfernandes committed Jun 30, 2020
1 parent d54b13e commit 5d961c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/dsql/Parser.cpp
Expand Up @@ -728,9 +728,9 @@ int Parser::yylexAux()

while (++lex.ptr + 1 < lex.end)
{
if (*lex.ptr == endChar && *++lex.ptr == '\'')
if (*lex.ptr == endChar && lex.ptr[1] == '\'')
{
size_t len = lex.ptr - lex.last_token - 4;
size_t len = ++lex.ptr - lex.last_token - 4;

if (len > MAX_STR_SIZE)
{
Expand Down
4 changes: 3 additions & 1 deletion src/isql/isql.epp
Expand Up @@ -5212,6 +5212,7 @@ static processing_state get_statement(Firebird::string& statement,

char lastChar = '\0';
char altQuoteChar = '\0';
unsigned altQuoteStringLength = 0;

while (!done)
{
Expand Down Expand Up @@ -5350,6 +5351,7 @@ static processing_state get_statement(Firebird::string& statement,
{
statement += (lastChar = c);
altQuoteChar = c = getNextInputChar();
altQuoteStringLength = statement.length();

switch (altQuoteChar)
{
Expand All @@ -5373,7 +5375,7 @@ static processing_state get_statement(Firebird::string& statement,
state = in_single_quoted_string;
break;
case in_single_quoted_string:
if (!altQuoteChar || lastChar == altQuoteChar)
if (!altQuoteChar || (statement.length() != altQuoteStringLength + 1 && lastChar == altQuoteChar))
state = normal;
break;
}
Expand Down

0 comments on commit 5d961c0

Please sign in to comment.