Skip to content

Commit dce47b3

Browse files
committed
grammar: Correctly parse double quotes as a means of escaping
This should parse the table and column names correctly by removing any double quote characters and replacing them by a single one. See issue #387.
1 parent 631979c commit dce47b3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/sqlitetypes.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,20 @@ QString identifier(antlr::RefAST ident)
256256
ident->getType() == Sqlite3Lexer::QUOTEDLITERAL ||
257257
ident->getType() == sqlite3TokenTypes::STRINGLITERAL)
258258
{
259+
// Remember the way the identifier is quoted
260+
QChar quoteChar = sident.at(0);
261+
262+
// Remove first and final character, i.e. the quotes
259263
sident.remove(0, 1);
260-
sident.remove(sident.length() - 1, 1);
264+
sident.chop(1);
265+
266+
// Replace all remaining occurences of two succeeding quote characters and replace them
267+
// by a single instance. This is done because two quotes can be used as a means of escaping
268+
// the quote character, thus only the visual representation has its two quotes, the actual
269+
// name contains only one.
270+
sident.replace(QString(quoteChar) + quoteChar, quoteChar);
261271
}
272+
262273
return sident;
263274
}
264275

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy