Import: UUID attribute is now validated

This commit is contained in:
Paul Beckingham
2015-08-09 10:20:25 -04:00
parent 2a621a4367
commit 4529bcf24a
11 changed files with 23 additions and 3 deletions

View File

@@ -1404,8 +1404,18 @@ void Task::validate (bool applyDefault /* = true */)
Task::status status = getStatus ();
// 1) Provide missing attributes where possible
// Provide a UUID if necessary.
if (! has ("uuid") || get ("uuid") == "")
// Provide a UUID if necessary. Validate if present.
std::string uid = get ("uuid");
if (has ("uuid") && uid != "")
{
Lexer lex (uid);
Lexer::Type type;
if (! lex.token (uid, type) ||
uid.length () != 36 ||
type != Lexer::Type::uuid)
throw format (STRING_CMD_IMPORT_UUID_BAD, uid);
}
else
set ("uuid", uuid ());
// Recurring tasks get a special status.