diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-12-29 11:20:18 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2017-02-22 16:53:45 +0100 |
commit | 24217e734c2ce603e0ff8bfa083535905955eff1 (patch) | |
tree | e528c71494cc6c912a029f48022bb13dc690f120 /apt-pkg/edsp.cc | |
parent | ab951bc3184d62d9bf9a94187468329e53ac0d0a (diff) |
ensure generation of valid EDSP error stanzas
The crude way of preparing a message to be a multiline value failed at
generation valid deb822 in case the error message ended with a new line
like the resolving errors from apt do. apt itself can parse these, but
other tools like grep-dctrl choke on it, so be nice and print valid.
Reported-By: Johannes 'josch' Schauer on IRC
(cherry picked from commit 0161280405fe5aa256dc9df6a56106dd3a1a6f38)
Diffstat (limited to 'apt-pkg/edsp.cc')
-rw-r--r-- | apt-pkg/edsp.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index b80b9a456..a2520441b 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -931,14 +931,18 @@ bool EDSP::WriteProgress(unsigned short const percent, const char* const message } /*}}}*/ // EDSP::WriteError - format an error message to be send to file descriptor /*{{{*/ +static std::string formatMessage(std::string const &msg) +{ + return SubstVar(SubstVar(APT::String::Strip(msg), "\n\n", "\n.\n"), "\n", "\n "); +} bool EDSP::WriteError(char const * const uuid, std::string const &message, FILE* output) { fprintf(output, "Error: %s\n", uuid); - fprintf(output, "Message: %s\n\n", SubstVar(SubstVar(message, "\n\n", "\n.\n"), "\n", "\n ").c_str()); + fprintf(output, "Message: %s\n\n", formatMessage(message).c_str()); return true; } bool EDSP::WriteError(char const * const uuid, std::string const &message, FileFd &output) { return WriteOkay(output, "Error: ", uuid, "\n", - "Message: ", SubstVar(SubstVar(message, "\n\n", "\n.\n"), "\n", "\n "), + "Message: ", formatMessage(message), "\n\n"); } /*}}}*/ |