mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 18:40:13 -06:00
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.
This commit is contained in:
@@ -256,9 +256,20 @@ QString identifier(antlr::RefAST ident)
|
||||
ident->getType() == Sqlite3Lexer::QUOTEDLITERAL ||
|
||||
ident->getType() == sqlite3TokenTypes::STRINGLITERAL)
|
||||
{
|
||||
// Remember the way the identifier is quoted
|
||||
QChar quoteChar = sident.at(0);
|
||||
|
||||
// Remove first and final character, i.e. the quotes
|
||||
sident.remove(0, 1);
|
||||
sident.remove(sident.length() - 1, 1);
|
||||
sident.chop(1);
|
||||
|
||||
// Replace all remaining occurences of two succeeding quote characters and replace them
|
||||
// by a single instance. This is done because two quotes can be used as a means of escaping
|
||||
// the quote character, thus only the visual representation has its two quotes, the actual
|
||||
// name contains only one.
|
||||
sident.replace(QString(quoteChar) + quoteChar, quoteChar);
|
||||
}
|
||||
|
||||
return sident;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user