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 {
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 (
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -316,13 +316,13 @@ namespace Astroid {
316316 bool use = false ;
317317
318318 if (c->siblings .size () >= 1 ) {
319- if (c->preferred ) {
319+ if (c->is_content_type ( " text " , html ? " html " : " plain " ) ) {
320320 use = true ;
321321 } else {
322322 /* check if there are any other preferred */
323323 if (all_of (c->siblings .begin (),
324324 c->siblings .end (),
325- [](refptr<Chunk> c) { return ( !c->preferred ); })) {
325+ [html ](refptr<Chunk> c) { return !c->is_content_type ( " text " , html ? " html " : " plain " ); })) {
326326 use = true ;
327327 } else {
328328 use = false ;
@@ -333,7 +333,7 @@ namespace Astroid {
333333 }
334334
335335 if (use) {
336- if (c->viewable && (c->preferred || html || fallback_html)) {
336+ if (c->viewable && (c->is_content_type ( " text " , html ? " html " : " plain " ) || fallback_html)) {
337337 body += c->viewable_text (html);
338338 }
339339
You can’t perform that action at this time.
0 commit comments