No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-parser-text-html.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-parser-text-html.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-parser-text-html.c
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
16 *
17 */
18
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include "e-mail-format-extensions.h"
24
25 #include <em-format/e-mail-parser-extension.h>
26 #include <em-format/e-mail-parser.h>
27 #include <em-format/e-mail-part-utils.h>
28 #include <e-util/e-util.h>
29
30 #include <glib/gi18n-lib.h>
31 #include <camel/camel.h>
32
33 #include <string.h>
34
35 typedef struct _EMailParserTextHTML {
36 GObject parent;
37 } EMailParserTextHTML;
38
39 typedef struct _EMailParserTextHTMLClass {
40 GObjectClass parent_class;
41 } EMailParserTextHTMLClass;
42
43 static void e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface);
44 static void e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface);
45
46 G_DEFINE_TYPE_EXTENDED (
47 EMailParserTextHTML,
48 e_mail_parser_text_html,
49 G_TYPE_OBJECT,
50 0,
51 G_IMPLEMENT_INTERFACE (
52 E_TYPE_MAIL_EXTENSION,
53 e_mail_parser_mail_extension_interface_init)
54 G_IMPLEMENT_INTERFACE (
55 E_TYPE_MAIL_PARSER_EXTENSION,
56 e_mail_parser_parser_extension_interface_init));
57
58 static const gchar *parser_mime_types[] = { "text/html", NULL };
59
60 static GSList *
61 empe_text_html_parse (EMailParserExtension *extension,
62 EMailParser *parser,
63 CamelMimePart *part,
64 GString *part_id,
65 GCancellable *cancellable)
66 {
67 EMailPart *empart;
68 const gchar *location;
69 gchar *cid = NULL;
70 const gchar *base;
71 gint len;
72
73 if (g_cancellable_is_cancelled (cancellable))
74 return NULL;
75
76 cid = NULL;
77 base = camel_medium_get_header (CAMEL_MEDIUM (part), "content-base");
78 location = camel_mime_part_get_content_location (part);
79 if (location != NULL) {
80 if (strchr (location, ':') == NULL && base != NULL) {
81 CamelURL *uri;
82 CamelURL *base_url = camel_url_new (base, NULL);
83
84 uri = camel_url_new_with_base (base_url, location);
85 cid = camel_url_to_string (uri, 0);
86 camel_url_free (uri);
87 camel_url_free (base_url);
88 } else {
89 cid = g_strdup (location);
90 }
91 }
92
93 len = part_id->len;
94 g_string_append (part_id, ".text_html");
95
96 empart = e_mail_part_new (part, part_id->str);
97 empart->mime_type = g_strdup ("text/html");
98 empart->cid = cid;
99 g_string_truncate (part_id, len);
100
101 if (e_mail_part_is_attachment (part)) {
102 return e_mail_parser_wrap_as_attachment (
103 parser, part, g_slist_append (NULL, empart),
104 part_id, cancellable);
105 }
106
107 return g_slist_append (NULL, empart);
108 }
109
110 static const gchar **
111 empe_text_html_mime_types (EMailExtension *extension)
112 {
113 return parser_mime_types;
114 }
115
116 static void
117 e_mail_parser_text_html_class_init (EMailParserTextHTMLClass *class)
118 {
119 }
120
121 static void
122 e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface)
123 {
124 iface->parse = empe_text_html_parse;
125 }
126
127 static void
128 e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface)
129 {
130 iface->mime_types = empe_text_html_mime_types;
131 }
132
133 static void
134 e_mail_parser_text_html_init (EMailParserTextHTML *parser)
135 {
136
137 }