[Box Backup-commit] COMMIT r3211 - in box/trunk: bin/bbackupquery test/bbackupd
subversion at boxbackup.org
subversion at boxbackup.org
Fri Feb 7 20:03:44 GMT 2014
Author: chris
Date: 2014-02-07 20:03:44 +0000 (Fri, 07 Feb 2014)
New Revision: 3211
Modified:
box/trunk/bin/bbackupquery/CommandCompletion.cpp
box/trunk/test/bbackupd/testbbackupd.cpp
Log:
Fix bbackupquery accepting a command starting with options.
This should never have been a valid command, but was accepted before, and
silently ignored because it was treated as an empty command. This obscured
bad quoting of bbackupquery command-line arguments, allowing commands to
appear to work, but not do what you expected.
Modified: box/trunk/bin/bbackupquery/CommandCompletion.cpp
===================================================================
--- box/trunk/bin/bbackupquery/CommandCompletion.cpp 2014-02-07 20:03:30 UTC (rev 3210)
+++ box/trunk/bin/bbackupquery/CommandCompletion.cpp 2014-02-07 20:03:44 UTC (rev 3211)
@@ -510,8 +510,10 @@
{
inQuoted = true;
}
- // Start of options?
- else if(currentArg.empty() && *c == '-')
+ // Start of options? You can't have options if there's no
+ // command before them, so treat the options as a command (which
+ // doesn't exist, so it will fail to parse) in that case.
+ else if(currentArg.empty() && *c == '-' && !mCmdElements.empty())
{
mInOptions = true;
}
Modified: box/trunk/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/trunk/test/bbackupd/testbbackupd.cpp 2014-02-07 20:03:30 UTC (rev 3210)
+++ box/trunk/test/bbackupd/testbbackupd.cpp 2014-02-07 20:03:44 UTC (rev 3211)
@@ -3953,6 +3953,14 @@
int test(int argc, const char *argv[])
{
{
+ // This is not a complete command, it should not parse!
+ BackupQueries::ParsedCommand cmd("-od", true);
+ TEST_THAT(cmd.mFailed);
+ TEST_EQUAL(NULL, cmd.pSpec);
+ TEST_EQUAL(0, cmd.mCompleteArgCount);
+ }
+
+ {
BackupDaemon daemon;
TEST_EQUAL(1234, daemon.ParseSyncAllowScriptOutput("test", "1234"));
More information about the Boxbackup-commit
mailing list