Skip to content

Commit

Permalink
Fixed|Resources|libdoomsday: Handle syntax errors in Snowberry-format…
Browse files Browse the repository at this point in the history
… metadata

Malformed packages get the "error" tag and the error message is included
in the package notes.

IssueID #2225
  • Loading branch information
skyjake committed Apr 16, 2017
1 parent 6ae9799 commit d849969
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion doomsday/apps/libdoomsday/src/resource/databundle.cpp
Expand Up @@ -570,7 +570,16 @@ DENG2_PIMPL(DataBundle), public Lockable
*/
void parseSnowberryInfo(File const &infoFile, Record &meta)
{
Info info(infoFile);
Info info;
String parseErrorMsg;
try
{
info.parse(infoFile);
}
catch (Error const &er)
{
parseErrorMsg = er.asText();
}
auto const &rootBlock = info.root();

// Tag it as a Snowberry package.
Expand Down Expand Up @@ -628,6 +637,13 @@ DENG2_PIMPL(DataBundle), public Lockable
}
}
}

if (parseErrorMsg)
{
meta.appendUniqueWord(VAR_TAGS, "error");
meta.set("notes", QObject::tr("There is an error in the metadata of this package: %1")
.arg(parseErrorMsg) + "\n\n" + meta.gets("notes", ""));
}
}

/**
Expand Down

0 comments on commit d849969

Please sign in to comment.