@@ -128,6 +128,23 @@ subscription_icon_download_html_cb (const struct updateResult * const result, gp
128
128
}
129
129
130
130
static GRegex * image_extension_match = NULL ;
131
+ static GRegex * image_mime_type_match = NULL ;
132
+
133
+ static void
134
+ subscription_icon_handle_response (const struct updateResult * const result , gpointer user_data , updateFlags flags )
135
+ {
136
+ if (!image_extension_match )
137
+ image_extension_match = g_regex_new ("\\.(ico|png|gif|jpg|svg)$" , G_REGEX_CASELESS , 0 , NULL );
138
+
139
+ if (!image_mime_type_match )
140
+ image_mime_type_match = g_regex_new ("^image/(png|gif|jpeg|svg+xml)$" , G_REGEX_CASELESS , 0 , NULL );
141
+
142
+ if ((result -> contentType && g_regex_match (image_mime_type_match , result -> contentType , 0 , NULL )) || g_regex_match (image_extension_match , result -> data , 0 , NULL )) {
143
+ subscription_icon_download_data_cb (result , user_data , flags );
144
+ } else {
145
+ subscription_icon_download_html_cb (result , user_data , flags );
146
+ }
147
+ }
131
148
132
149
/* Performs a download of the first URL in ctxt->urls */
133
150
static void
@@ -156,15 +173,7 @@ subscription_icon_download_next (iconDownloadCtxtPtr ctxt)
156
173
ctxt -> options
157
174
);
158
175
159
- if (!image_extension_match )
160
- image_extension_match = g_regex_new ("\\.(ico|png|gif|jpg|svg)$" , G_REGEX_CASELESS , 0 , NULL );
161
-
162
- if (g_regex_match (image_extension_match , url , 0 , NULL ))
163
- callback = subscription_icon_download_data_cb ;
164
- else
165
- callback = subscription_icon_download_html_cb ;
166
-
167
- update_execute_request (node_from_id (ctxt -> id ), request , callback , ctxt , FEED_REQ_PRIORITY_HIGH | FEED_REQ_NO_FEED );
176
+ update_execute_request (node_from_id (ctxt -> id ), request , subscription_icon_handle_response , ctxt , FEED_REQ_PRIORITY_HIGH | FEED_REQ_NO_FEED );
168
177
} else {
169
178
debug (DEBUG_UPDATE , "Icon '%s' discovery/download failed!" , ctxt -> id );
170
179
subscription_icon_download_ctxt_free (ctxt );
0 commit comments