/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
GdkPixbuf *pixbuf;
GError *error = NULL;
ClickableText *uri;
- GInputStream *stream;
START_TIMING("inserting image");
- stream = procmime_get_part_as_inputstream(mimeinfo, &error);
- if (error != NULL) {
- g_warning("Can't get the image file: %s", error->message);
- g_error_free(error);
- END_TIMING();
- return;
- }
-
- pixbuf = gdk_pixbuf_new_from_stream(stream, NULL, &error);
- g_object_unref(stream);
-
+ pixbuf = procmime_get_part_as_pixbuf(mimeinfo, &error);
if (error != NULL) {
g_warning("Can't load the image: %s\n", error->message);
g_error_free(error);
END_TIMING();
return;
}
+
if (textview->stop_loading) {
END_TIMING();
return;
textview->is_in_signature = FALSE;
textview->is_diff = FALSE;
textview->is_attachment = FALSE;;
+ textview->is_in_git_patch = FALSE;
procmime_decode_content(mimeinfo);
- account_signatures_matchlist_create();
+ account_sigsep_matchlist_create();
if (!g_ascii_strcasecmp(mimeinfo->subtype, "html") &&
prefs_common.render_html) {
claws_fclose(tmpfp);
waitpid(pid, pfd, 0);
g_unlink(fname);
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
return;
}
}
tmpfp = claws_fopen(mimeinfo->data.filename, "rb");
if (!tmpfp) {
FILE_OP_ERROR(mimeinfo->data.filename, "claws_fopen");
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
return;
}
if (fseek(tmpfp, mimeinfo->offset, SEEK_SET) < 0) {
FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
claws_fclose(tmpfp);
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
return;
}
debug_print("Viewing text content of type: %s (length: %d)\n", mimeinfo->subtype, mimeinfo->length);
textview_write_line(textview, buf, conv, TRUE);
if (textview->stop_loading) {
claws_fclose(tmpfp);
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
return;
}
wrote += ftell(tmpfp)-i;
claws_fclose(tmpfp);
}
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
conv_code_converter_destroy(conv);
procmime_force_encoding(0);
parser = sc_html_parser_new(fp, conv);
cm_return_if_fail(parser != NULL);
- account_signatures_matchlist_create();
+ account_sigsep_matchlist_create();
while ((str = sc_html_parse(parser)) != NULL) {
if (parser->state == SC_HTML_HREF) {
if (lines % 500 == 0)
GTK_EVENTS_FLUSH();
if (textview->stop_loading) {
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
return;
}
}
textview_write_line(textview, "\n", NULL, FALSE);
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
sc_html_parser_destroy(parser);
}
parser = ertf_parser_new(fp, conv);
cm_return_if_fail(parser != NULL);
- account_signatures_matchlist_create();
+ account_sigsep_matchlist_create();
while ((str = ertf_parse(parser)) != NULL) {
textview_write_line(textview, str, NULL, FALSE);
if (lines % 500 == 0)
GTK_EVENTS_FLUSH();
if (textview->stop_loading) {
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
return;
}
}
- account_signatures_matchlist_delete();
+ account_sigsep_matchlist_delete();
ertf_parser_destroy(parser);
}
}
if (prefs_common.enable_color) {
- if (textview->is_diff) {
+ if (textview->is_diff || textview->is_in_git_patch) {
if (strncmp(buf, "+++ ", 4) == 0)
fg_color = "diff-add-file";
else if (buf[0] == '+')
else if (buf[0] == '-')
fg_color = "diff-del";
else if (strncmp(buf, "@@ ", 3) == 0 &&
- strcmp(buf+strlen(buf)-4, " @@\n") == 0)
+ strstr(&buf[3], " @@"))
fg_color = "diff-hunk";
- } else if (account_signatures_matchlist_str_found(buf,"%s\n")
- || account_signatures_matchlist_str_found(buf, "- %s\n")
+
+ if (account_sigsep_matchlist_nchar_found(buf, "%s\n")) {
+ textview->is_in_git_patch = FALSE;
+ textview->is_in_signature = TRUE;
+ fg_color = "signature";
+ }
+ } else if (account_sigsep_matchlist_str_found(buf, "%s\n")
+ || account_sigsep_matchlist_str_found(buf, "- %s\n")
|| textview->is_in_signature) {
fg_color = "signature";
textview->is_in_signature = TRUE;
+ } else if (strncmp(buf, "diff --git ", 11) == 0) {
+ textview->is_in_git_patch = TRUE;
}
}
const gchar *raw_url = g_object_get_data(G_OBJECT(textview->link_popup_menu),
"raw_url");
if (uri) {
- gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), uri->uri, -1);
- gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), uri->uri, -1);
- g_object_set_data(G_OBJECT(textview->link_popup_menu), "menu_button",
- NULL);
+ if (textview_uri_security_check(textview, uri) == TRUE) {
+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), uri->uri, -1);
+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), uri->uri, -1);
+ g_object_set_data(G_OBJECT(textview->link_popup_menu), "menu_button", NULL);
+ }
}
if (raw_url) {
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), raw_url, -1);
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), raw_url, -1);
- g_object_set_data(G_OBJECT(textview->link_popup_menu), "raw_url",
- NULL);
+ g_object_set_data(G_OBJECT(textview->link_popup_menu), "raw_url", NULL);
}
}