Skip to content

Commit 6bc1073

Browse files
committed
Support quotes strings in Console
1 parent eefed3e commit 6bc1073

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

redis-desktop-manager/source/redis/Command.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,33 @@ void Command::setOwner(QObject * o)
8585

8686
QByteArray Command::getByteRepresentation(const QString& command)
8787
{
88-
QStringList parts = command.split(" ", QString::SkipEmptyParts, Qt::CaseInsensitive);
89-
88+
QStringList parts = QStringList();
89+
int i = 0;
90+
bool inQuote = false;
91+
QString part = QString();
92+
while (i < command.length())
93+
{
94+
if(command.at(i).isSpace() && !inQuote)
95+
{
96+
if (part.length() > 0)
97+
parts.append(part);
98+
part = QString();
99+
}
100+
else if (command.at(i) == QChar('"'))
101+
{
102+
if (inQuote)
103+
parts.append(part);
104+
part = QString();
105+
inQuote = !inQuote;
106+
}
107+
else
108+
{
109+
part.append(command.at(i));
110+
}
111+
++i;
112+
}
113+
if (parts.length() < 1 || part.length() > 0)
114+
parts.append(part);
90115
return Command::getByteRepresentation(parts);
91116
}
92117

0 commit comments

Comments
 (0)