Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/controller/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
#include <QStyleHints>
#include <QTranslator>

inline CommandWithArguments::second_type parseArgumentJson(const QString& argumentStr)
inline CommandWithArguments::second_type parseArgumentJson(const QByteArray& argumentBytes)
{
const auto argumentJson = QJsonDocument::fromJson(argumentStr.toUtf8());
if (argumentBytes.size() > 8192) {
throw ArgumentError("Command argument JSON length exceeds maximum allowed 8192 bytes");
}
const auto argumentJson = QJsonDocument::fromJson(argumentBytes);

if (!argumentJson.isObject()) {
throw ArgumentError("parseArgument: Invalid JSON, not an object");
Expand Down Expand Up @@ -167,7 +170,7 @@ CommandWithArguments Application::parseArgs()
if (command == CMDLINE_GET_SIGNING_CERTIFICATE || command == CMDLINE_AUTHENTICATE
|| command == CMDLINE_SIGN) {
// TODO: add command-specific argument validation
return {CommandType(command), parseArgumentJson(arguments)};
return {CommandType(command), parseArgumentJson(arguments.toUtf8())};
}
throw ArgumentError("The command has to be one of " + COMMANDS.toStdString());
}
Expand Down
Loading