File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,10 @@ namespace Astroid {
238
238
239
239
}
240
240
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
+
241
245
ustring Chunk::viewable_text (bool html = true , bool verbose) {
242
246
if (isencrypted && !crypt->decrypted ) {
243
247
if (verbose) {
@@ -258,7 +262,7 @@ namespace Astroid {
258
262
LOG (debug) << " chunk: body: part" ;
259
263
260
264
261
- if (g_mime_content_type_is_type (content_type, " text" , " plain" )) {
265
+ if (is_content_type ( " text" , " plain" )) {
262
266
LOG (debug) << " chunk: plain text (out html: " << html << " )" ;
263
267
264
268
GMimeDataWrapper * content = g_mime_part_get_content (
@@ -328,7 +332,7 @@ namespace Astroid {
328
332
329
333
content_stream = filter_stream;
330
334
331
- } else if (g_mime_content_type_is_type (content_type, " text" , " html" )) {
335
+ } else if (is_content_type ( " text" , " html" )) {
332
336
LOG (debug) << " chunk: html text" ;
333
337
334
338
GMimeDataWrapper * content = g_mime_part_get_content (
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ namespace Astroid {
30
30
ustring content_id;
31
31
32
32
ustring get_content_type ();
33
+ bool is_content_type (const char * major, const char * minor);
33
34
34
35
ustring viewable_text (bool , bool verbose = false );
35
36
Original file line number Diff line number Diff line change @@ -324,13 +324,13 @@ namespace Astroid {
324
324
bool use = false ;
325
325
326
326
if (c->siblings .size () >= 1 ) {
327
- if (c->preferred ) {
327
+ if (c->is_content_type ( " text " , html ? " html " : " plain " ) ) {
328
328
use = true ;
329
329
} else {
330
330
/* check if there are any other preferred */
331
331
if (all_of (c->siblings .begin (),
332
332
c->siblings .end (),
333
- [](refptr<Chunk> c) { return ( !c->preferred ); })) {
333
+ [html ](refptr<Chunk> c) { return !c->is_content_type ( " text " , html ? " html " : " plain " ); })) {
334
334
use = true ;
335
335
} else {
336
336
use = false ;
@@ -341,7 +341,7 @@ namespace Astroid {
341
341
}
342
342
343
343
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)) {
345
345
body += c->viewable_text (html);
346
346
}
347
347
You can’t perform that action at this time.
0 commit comments