Skip to content

Commit b11b356

Browse files
committed
mt, chunk: always return text/plain when html == false.
1 parent b571187 commit b11b356

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/chunk.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ namespace Astroid {
238238

239239
}
240240

241+
bool Chunk::is_content_type (const char * major, const char * minor) {
242+
return (mime_object != NULL) && g_mime_content_type_is_type (content_type, major, minor);
243+
}
244+
241245
ustring Chunk::viewable_text (bool html = true, bool verbose) {
242246
if (isencrypted && !crypt->decrypted) {
243247
if (verbose) {
@@ -258,7 +262,7 @@ namespace Astroid {
258262
LOG (debug) << "chunk: body: part";
259263

260264

261-
if (g_mime_content_type_is_type (content_type, "text", "plain")) {
265+
if (is_content_type ("text", "plain")) {
262266
LOG (debug) << "chunk: plain text (out html: " << html << ")";
263267

264268
GMimeDataWrapper * content = g_mime_part_get_content (
@@ -328,7 +332,7 @@ namespace Astroid {
328332

329333
content_stream = filter_stream;
330334

331-
} else if (g_mime_content_type_is_type (content_type, "text", "html")) {
335+
} else if (is_content_type ("text", "html")) {
332336
LOG (debug) << "chunk: html text";
333337

334338
GMimeDataWrapper * content = g_mime_part_get_content (

src/chunk.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace Astroid {
3030
ustring content_id;
3131

3232
ustring get_content_type ();
33+
bool is_content_type (const char* major, const char* minor);
3334

3435
ustring viewable_text (bool, bool verbose = false);
3536

src/message_thread.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,13 @@ namespace Astroid {
324324
bool use = false;
325325

326326
if (c->siblings.size() >= 1) {
327-
if (c->preferred) {
327+
if (c->is_content_type ("text", html ? "html" : "plain")) {
328328
use = true;
329329
} else {
330330
/* check if there are any other preferred */
331331
if (all_of (c->siblings.begin (),
332332
c->siblings.end (),
333-
[](refptr<Chunk> c) { return (!c->preferred); })) {
333+
[html](refptr<Chunk> c) { return !c->is_content_type ("text", html ? "html" : "plain"); })) {
334334
use = true;
335335
} else {
336336
use = false;
@@ -341,7 +341,7 @@ namespace Astroid {
341341
}
342342

343343
if (use) {
344-
if (c->viewable && (c->preferred || html || fallback_html)) {
344+
if (c->viewable && (c->is_content_type ("text", html ? "html" : "plain") || fallback_html)) {
345345
body += c->viewable_text (html);
346346
}
347347

0 commit comments

Comments
 (0)