diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-21 20:53:22 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-21 20:53:22 +0100 |
commit | 335987655eafabe99d0f4b2fecc0f84e31636b77 (patch) | |
tree | 49a7870c9f4fe39d3ab5178fb33262bfdd25fe83 /lib/Utils/make_descr.cpp | |
parent | f3d791f2069f8047b909408cd452cd9cc97df400 (diff) | |
download | abrt-335987655eafabe99d0f4b2fecc0f84e31636b77.tar.gz abrt-335987655eafabe99d0f4b2fecc0f84e31636b77.tar.xz abrt-335987655eafabe99d0f4b2fecc0f84e31636b77.zip |
fix bz description text disrupted by recent dbus security fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Utils/make_descr.cpp')
-rw-r--r-- | lib/Utils/make_descr.cpp | 95 |
1 files changed, 65 insertions, 30 deletions
diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp index a3ff5e24..b67dfe65 100644 --- a/lib/Utils/make_descr.cpp +++ b/lib/Utils/make_descr.cpp @@ -50,50 +50,85 @@ static void add_content(bool &was_multiline, string& description, const char *he } } +static const char *const blacklisted_items_bz[] = { + FILENAME_TIME , + FILENAME_UID , + FILENAME_UUID , + FILENAME_ANALYZER , + FILENAME_COREDUMP , + FILENAME_DESCRIPTION, /* package description - basically useless */ + CD_DUPHASH , + CD_UUID , + CD_DUMPDIR , + CD_COUNT , + CD_REPORTED , + CD_MESSAGE , + NULL +}; + string make_description_bz(const map_crash_data_t& pCrashData) { string description; + string long_description; - map_crash_data_t::const_iterator it; - map_crash_data_t::const_iterator end = pCrashData.end(); - - bool was_multiline = 0; - it = pCrashData.find(FILENAME_REPRODUCE); - if (it != end && it->second[CD_CONTENT] != "1.\n2.\n3.\n") - { - add_content(was_multiline, description, "How to reproduce", it->second[CD_CONTENT].c_str()); - } - - it = pCrashData.find(FILENAME_COMMENT); - if (it != end) - { - add_content(was_multiline, description, "Comment", it->second[CD_CONTENT].c_str()); - } - - it = pCrashData.begin(); - for (; it != end; it++) + map_crash_data_t::const_iterator it = pCrashData.begin(); + for (; it != pCrashData.end(); it++) { - const string &filename = it->first; - const string &type = it->second[CD_TYPE]; - const string &content = it->second[CD_CONTENT]; + const string& itemname = it->first; + const string& type = it->second[CD_TYPE]; + const string& content = it->second[CD_CONTENT]; if (type == CD_TXT) { + /* Skip items we are not interested in */ + const char *const *bl = blacklisted_items_bz; + while (*bl) + { + if (itemname == *bl) + break; + bl++; + } + if (*bl) + continue; /* blacklisted */ + if (content == "1.\n2.\n3.\n") + continue; /* user did not change default "How to reproduce" */ + if (content.size() <= CD_TEXT_ATT_SIZE) { - if (filename != CD_DUPHASH - && filename != FILENAME_ARCHITECTURE - && filename != FILENAME_RELEASE - && filename != FILENAME_REPRODUCE - && filename != FILENAME_COMMENT - ) { - add_content(was_multiline, description, filename.c_str(), content.c_str()); + /* Add small (less than few kb) text items inline */ + bool was_multiline = 0; + string tmp; + add_content(was_multiline, + tmp, + /* "reproduce: blah" looks ugly, fixing: */ + itemname == FILENAME_REPRODUCE ? "How to reproduce" : itemname.c_str(), + content.c_str() + ); + + if (was_multiline) + { + /* Not one-liner */ + if (long_description.size() != 0) + long_description += '\n'; + long_description += tmp; + } + else + { + description += tmp; } } else { - add_content(was_multiline, description, "Attached file", filename.c_str()); + bool was_multiline = 0; + add_content(was_multiline, description, "Attached file", itemname.c_str()); } } } + /* One-liners go first, then multi-line items */ + if (description.size() != 0 && long_description.size() != 0) + { + description += '\n'; + } + description += long_description; + return description; } @@ -134,8 +169,8 @@ string make_description_logger(const map_crash_data_t& pCrashData) if (description.size() != 0 && long_description.size() != 0) { description += '\n'; - description += long_description; } + description += long_description; return description; } |