Commit 57aa3bce authored by Milan Crha's avatar Milan Crha

Address some issues reported by static analyzers (Coverity Scan, clang)

parent 47de7921
......@@ -368,7 +368,7 @@ contact_display_link_clicked (EWebView *web_view,
}
length = strlen ("open-map:");
if (g_str_has_prefix (uri, "open-map:")) {
if (g_ascii_strncasecmp (uri, "open-map:", length)) {
SoupURI *suri;
suri = soup_uri_new (uri);
......
......@@ -670,8 +670,8 @@ datetime_to_zone (ECalClient *client,
if (!from) {
GError *error = NULL;
e_cal_client_get_timezone_sync (
client, e_cal_component_datetime_get_tzid (date), &from, NULL, &error);
if (!e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (date), &from, NULL, &error))
from = NULL;
if (error != NULL) {
g_warning (
......@@ -685,7 +685,8 @@ datetime_to_zone (ECalClient *client,
to = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
if (!to) {
/* do not check failure here, maybe the zone is not available there */
e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL);
if (!e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL))
to = NULL;
}
i_cal_time_convert_timezone (e_cal_component_datetime_get_value (date), from, to);
......
......@@ -166,7 +166,8 @@ timet_to_str_with_zone (ECalComponentDateTime *dt,
itt = e_cal_component_datetime_get_value (dt);
if (e_cal_component_datetime_get_tzid (dt)) {
e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (dt), &zone, NULL, NULL);
if (!e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (dt), &zone, NULL, NULL))
zone = NULL;
} else if (i_cal_time_is_utc (itt)) {
zone = i_cal_timezone_get_utc_timezone ();
}
......
......@@ -660,7 +660,7 @@ get_current_time (ECalendarItem *calitem,
{
ICalTimezone *zone;
ICalTime *tt;
struct tm tmp_tm = { 0 };
struct tm tmp_tm;
/* Get the current timezone. */
zone = calendar_config_get_icaltimezone ();
......
......@@ -1384,7 +1384,7 @@ e_calendar_view_get_paste_target_list (ECalendarView *cal_view)
gint
e_calendar_view_get_time_divisions (ECalendarView *cal_view)
{
g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), 0);
g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), 30);
return cal_view->priv->time_divisions;
}
......@@ -1395,6 +1395,10 @@ e_calendar_view_set_time_divisions (ECalendarView *cal_view,
{
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
/* To avoid division-by-zero and negative values on places where this is used */
if (time_divisions <= 0)
time_divisions = 30;
if (cal_view->priv->time_divisions == time_divisions)
return;
......@@ -2134,7 +2138,7 @@ e_calendar_view_dup_component_summary (ICalComponent *icomp)
The string is used for Birthday & Anniversary events where the first year is
know, constructing a summary which also shows how many years the birthday or
anniversary is for. Example: "Birthday: John Doe (13)" */
summary = g_strdup_printf (C_("BirthdaySummary", "%s (%d)"), summary ? summary : "", i_cal_time_get_year (dtstart) - since_year);
res = g_strdup_printf (C_("BirthdaySummary", "%s (%d)"), summary ? summary : "", i_cal_time_get_year (dtstart) - since_year);
}
g_clear_object (&dtstart);
......
......@@ -3197,9 +3197,6 @@ e_day_view_remove_event_cb (EDayView *day_view,
EDayViewEvent, event_num);
}
if (!event)
return TRUE;
/* If we were editing this event, set editing_event_day to -1 so
* on_editing_stopped doesn't try to update the event. */
if (day_view->editing_event_num == event_num && day_view->editing_event_day == day) {
......
......@@ -2051,7 +2051,6 @@ soup_authenticate (SoupSession *session,
if (password) {
soup_auth_authenticate (auth, suri->user, password);
tried = TRUE;
memset (password, 0, strlen (password));
g_free (password);
......
......@@ -512,9 +512,10 @@ memo_table_query_tooltip (GtkWidget *widget,
zone = i_cal_component_get_timezone (
e_cal_component_get_icalcomponent (new_comp),
e_cal_component_datetime_get_tzid (dtstart));
if (!zone)
e_cal_client_get_timezone_sync (
comp_data->client, e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, NULL);
if (!zone) {
if (!e_cal_client_get_timezone_sync (comp_data->client, e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, NULL))
zone = NULL;
}
if (!zone)
zone = default_zone;
} else {
......@@ -931,7 +932,10 @@ get_selected_comp (EMemoTable *memo_table)
row = -1;
e_table_selected_row_foreach (
E_TABLE (memo_table), get_selected_row_cb, &row);
g_return_val_if_fail (row != -1, NULL);
if (row < 0) {
g_warn_if_reached ();
return NULL;
}
return e_cal_model_get_component_at (model, row);
}
......
......@@ -262,4 +262,5 @@ e_select_names_editable_set_address (ESelectNamesEditable *esne,
destination_store, destination);
g_object_unref (destination);
g_list_free (list);
}
......@@ -188,7 +188,6 @@ e_send_options_utils_fill_component (ESendOptionsDialog *sod,
ECalComponent *comp,
ICalTimezone *zone)
{
gint ii;
ICalProperty *prop;
ICalComponent *icomp;
ESendOptionsGeneral *gopts;
......@@ -197,10 +196,6 @@ e_send_options_utils_fill_component (ESendOptionsDialog *sod,
gopts = sod->data->gopts;
sopts = sod->data->sopts;
ii = e_cal_component_get_sequence (comp);
if (ii < 1)
ii = 1;
icomp = e_cal_component_get_icalcomponent (comp);
if (e_send_options_get_need_general_options (sod)) {
......
......@@ -850,9 +850,10 @@ task_table_query_tooltip (GtkWidget *widget,
zone = i_cal_component_get_timezone (
e_cal_component_get_icalcomponent (new_comp),
e_cal_component_datetime_get_tzid (dtstart));
if (!zone)
e_cal_client_get_timezone_sync (
comp_data->client, e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, NULL);
if (!zone) {
if (!e_cal_client_get_timezone_sync (comp_data->client, e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, NULL))
zone = NULL;
}
if (!zone)
zone = default_zone;
} else {
......@@ -1305,7 +1306,10 @@ get_selected_comp (ETaskTable *task_table)
row = -1;
e_table_selected_row_foreach (
E_TABLE (task_table), get_selected_row_cb, &row);
g_return_val_if_fail (row != -1, NULL);
if (row < 0) {
g_warn_if_reached ();
return NULL;
}
return e_cal_model_get_component_at (model, row);
}
......
......@@ -2753,8 +2753,6 @@ e_week_view_remove_event_cb (EWeekView *week_view,
return TRUE;
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
if (!event)
return TRUE;
/* If we were editing this event, set editing_event_num to -1 so
* on_editing_stopped doesn't try to update the event. */
......
......@@ -1725,6 +1725,8 @@ print_day_details (GtkPrintContext *context,
/* use font like with 30 minutes time division */
rows_with_30_mins = (pdi.end_hour - pdi.start_hour) * (60 / 30);
if (rows_with_30_mins <= 0)
rows_with_30_mins = 2;
pango_font_description_free (font);
......@@ -2890,6 +2892,8 @@ print_work_week_day_details (GtkPrintContext *context,
/* use font like with 30 minutes time division */
rows_with_30_mins = (pdi.end_hour - pdi.start_hour) * (60 / 30);
if (rows_with_30_mins <= 0)
rows_with_30_mins = 2;
pango_font_description_free (font);
......
......@@ -305,8 +305,6 @@ alert_bar_constructed (GObject *object)
priv->secondary_label = widget;
gtk_widget_show (widget);
container = action_area;
/* Disable animation of the revealer, until GtkInfoBar's bug #710888 is fixed */
revealer = gtk_widget_get_template_child (GTK_WIDGET (object), GTK_TYPE_INFO_BAR, "revealer");
if (revealer) {
......
......@@ -240,12 +240,6 @@ e_html_editor_find_dialog_init (EHTMLEditorFindDialog *dialog)
gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
dialog->priv->result_label = widget;
widget = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
gtk_box_set_spacing (GTK_BOX (widget), 5);
gtk_button_box_set_layout (GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_END);
gtk_box_pack_end (box, widget, TRUE, TRUE, 0);
box = GTK_BOX (widget);
box = e_html_editor_dialog_get_button_box (E_HTML_EDITOR_DIALOG (dialog));
widget = e_dialog_button_new_with_icon ("edit-find", _("_Find"));
gtk_box_pack_start (box, widget, FALSE, FALSE, 5);
......
......@@ -1146,7 +1146,10 @@ model_section_removed (ENameSelectorDialog *name_selector_dialog,
gint section_index;
section_index = find_section_by_name (name_selector_dialog, name);
g_return_if_fail (section_index >= 0);
if (section_index < 0) {
g_warn_if_reached ();
return;
}
free_section (name_selector_dialog, section_index);
g_array_remove_index (
......@@ -1272,13 +1275,9 @@ source_changed (ENameSelectorDialog *name_selector_dialog,
{
GCancellable *cancellable;
ESource *source;
gpointer parent;
source = e_source_combo_box_ref_active (E_SOURCE_COMBO_BOX (combo_box));
parent = gtk_widget_get_toplevel (GTK_WIDGET (name_selector_dialog));
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
/* Remove any previous books being shown or loaded */
remove_books (name_selector_dialog);
......@@ -1495,6 +1494,7 @@ remove_selection (ENameSelectorDialog *name_selector_dialog,
Section *section;
GtkTreeSelection *selection;
GList *rows, *l;
gboolean res = TRUE;
section_index = find_section_by_tree_view (
name_selector_dialog, tree_view);
......@@ -1525,21 +1525,26 @@ remove_selection (ENameSelectorDialog *name_selector_dialog,
GtkTreeIter iter;
GtkTreePath *path = l->data;
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (destination_store), &iter, path))
g_return_val_if_reached (FALSE);
gtk_tree_path_free (path);
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (destination_store), &iter, path)) {
g_warn_if_reached ();
res = FALSE;
break;
}
destination = e_destination_store_get_destination (
destination_store, &iter);
g_return_val_if_fail (destination, FALSE);
destination = e_destination_store_get_destination (destination_store, &iter);
if (!destination) {
g_warn_if_reached ();
res = FALSE;
break;
}
e_destination_store_remove_destination (
destination_store, destination);
}
g_list_free (rows);
return TRUE;
g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
return res;
}
static void
......@@ -1616,21 +1621,15 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog,
GtkTreeIter iter;
GtkTreePath *path = l->data;
if (!gtk_tree_model_get_iter (
GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort),
&iter, path)) {
gtk_tree_path_free (path);
return;
}
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort), &iter, path))
break;
gtk_tree_path_free (path);
sort_iter_to_contact_store_iter (name_selector_dialog, &iter, &email_n);
contact = e_contact_store_get_contact (contact_store, &iter);
if (!contact) {
g_warning ("ENameSelectorDialog could not get selected contact!");
g_list_free (rows);
return;
break;
}
add_destination (
......@@ -1638,7 +1637,8 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog,
destination_store, contact, email_n,
e_contact_store_get_client (contact_store, &iter));
}
g_list_free (rows);
g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
}
/* --------------------- *
......
......@@ -623,10 +623,12 @@ e_name_selector_model_get_contact_emails_without_used (ENameSelectorModel *name_
} else {
GList *nth = g_list_nth (email_list, email_num);
g_return_val_if_fail (nth != NULL, NULL);
g_free (nth->data);
nth->data = NULL;
if (nth) {
g_free (nth->data);
nth->data = NULL;
} else {
g_warn_if_reached ();
}
}
}
}
......
......@@ -1419,10 +1419,8 @@ e_tree_table_adapter_load_expanded_state_xml (ETreeTableAdapter *etta,
/* Incase the default is changed, lets forget the changes and stick to default */
if (file_default != model_default) {
xmlFreeDoc (doc);
if (file_default != model_default)
return;
}
for (child = root->xmlChildrenNode; child; child = child->next) {
gchar *id;
......
......@@ -90,7 +90,8 @@ e_utf8_from_iconv_string_sized (iconv_t ic,
for (i = 0; i < (bytes); i++) {
ob += e_unichar_to_utf8 (ib[i], ob);
}
*ob = '\0';
if (ob)
*ob = '\0';
return new;
}
......
......@@ -1101,9 +1101,9 @@ test_utils_get_content_editor (TestFixture *fixture)
gchar *
test_utils_get_base64_data_for_image (const gchar *path)
{
gchar *image_data;
gchar *image_data = NULL;
gchar *image_data_base64;
gsize image_data_length;
gsize image_data_length = 0;
gboolean success;
GError *error = NULL;
......
......@@ -96,6 +96,8 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
while (link != NULL) {
p = link->data;
p_id = e_mail_part_get_id (p);
if (g_strcmp0 (p_id, sub_end) == 0)
break;
......@@ -164,6 +166,8 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
while (link != NULL) {
p = link->data;
p_id = e_mail_part_get_id (p);
if (g_strcmp0 (p_id, sub_end) == 0)
break;
......
......@@ -105,6 +105,8 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension,
while (link != NULL) {
p = link->data;
p_id = e_mail_part_get_id (p);
if (g_strcmp0 (p_id, sub_end) == 0)
break;
......
......@@ -87,7 +87,7 @@ strip_signature (CamelMimeFilter *filter,
}
}
while (inptr < inend) {
while (inptr && inptr < inend) {
if ((inend - inptr) >= 4 && !strncmp (inptr, "-- \n", 4)) {
start = inptr;
inptr += 4;
......
......@@ -67,8 +67,6 @@ sort_order_dialog_selection_changed_cb (GtkTreeSelection *selection,
gtk_tree_model_iter_children (model, &iter, &parent);
if (can) {
can = FALSE;
do {
guint sort_order = 0;
......
......@@ -1009,8 +1009,6 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
content = widget;
widget = GTK_WIDGET (html_editor);
notes_editor->editor = html_editor;
cnt_editor = e_html_editor_get_content_editor (notes_editor->editor);
ui_manager = e_html_editor_get_ui_manager (notes_editor->editor);
......
......@@ -197,7 +197,7 @@ mail_request_process_mail_sync (EContentRequest *request,
-1);
if (icon) {
const gchar *size = uri_query ? g_hash_table_lookup (uri_query, "size") : NULL;
const gchar *size = g_hash_table_lookup (uri_query, "size");
if (!size)
size = "16";
......@@ -236,7 +236,7 @@ mail_request_process_mail_sync (EContentRequest *request,
}
g_free (part_id);
mime_type = uri_query ? g_hash_table_lookup (uri_query, "mime_type") : NULL;
mime_type = g_hash_table_lookup (uri_query, "mime_type");
if (context.mode == E_MAIL_FORMATTER_MODE_SOURCE)
mime_type = "application/vnd.evolution.source";
......
......@@ -2373,7 +2373,7 @@ e_mail_templates_store_build_model (EMailTemplatesStore *templates_store,
GSList *link;
gint multiple_accounts = 0;
gboolean found_first_message = FALSE;
GtkTreeIter found_first_iter;
GtkTreeIter found_first_iter = { 0, };
g_return_val_if_fail (E_IS_MAIL_TEMPLATES_STORE (templates_store), NULL);
......
......@@ -711,7 +711,6 @@ subscription_editor_pick_shown (EMSubscriptionEditor *editor,
TreeRowData *tree_row_data;
gboolean is_expanded = FALSE;
found = FALSE;
tree_row_data = subscription_editor_tree_row_data_from_iter (
tree_view, tree_model, &iter, &is_expanded);
......
......@@ -428,7 +428,8 @@ cal_shell_content_datepicker_selection_changed_cb (ECalendarItem *calitem,
g_date_clear (&sel_start, 1);
g_date_clear (&sel_end, 1);
e_calendar_item_get_selection (calitem, &sel_start, &sel_end);
if (!e_calendar_item_get_selection (calitem, &sel_start, &sel_end))
return;
start_julian = g_date_get_julian (&sel_start);
end_julian = g_date_get_julian (&sel_end);
......@@ -622,7 +623,8 @@ cal_shell_content_datepicker_button_press_cb (ECalendar *calendar,
g_date_clear (&sel_start, 1);
g_date_clear (&sel_end, 1);
e_calendar_item_get_selection (calitem, &sel_start, &sel_end);
if (!e_calendar_item_get_selection (calitem, &sel_start, &sel_end))
return FALSE;
/* Switch to a day view on a double-click */
e_cal_shell_content_change_view (cal_shell_content, E_CAL_VIEW_KIND_DAY, &sel_start, &sel_start, FALSE);
......
......@@ -90,7 +90,6 @@ cal_shell_view_execute_search (EShellView *shell_view)
ECalDataModel *data_model;
GtkRadioAction *action;
ICalTimezone *timezone;
const gchar *default_tzloc = NULL;
ICalTime *current_time;
time_t start_range;
time_t end_range;
......@@ -117,11 +116,6 @@ cal_shell_view_execute_search (EShellView *shell_view)
now_time = time_day_begin (i_cal_time_as_timet (current_time));
g_clear_object (&current_time);
if (timezone && timezone != i_cal_timezone_get_utc_timezone ())
default_tzloc = i_cal_timezone_get_location (timezone);
if (!default_tzloc)
default_tzloc = "";
action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ANY_FIELD_CONTAINS));
value = gtk_radio_action_get_current_value (action);
......
......@@ -1579,8 +1579,6 @@ e_mail_shell_view_update_labels_sensitivity (EShellWindow *shell_window,
widget = gtk_widget_get_parent (widget);
}
reader = E_MAIL_READER (e_mail_shell_content_get_mail_view (mail_shell_view->priv->mail_shell_content));
action_group = e_mail_reader_get_action_group (reader, E_MAIL_READER_ACTION_GROUP_LABELS);
if (action_group)
gtk_action_group_set_sensitive (action_group, sensitive);
......
......@@ -406,14 +406,7 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
*
* Just return FALSE here and EMailFormatter will automatically
* fall back to the default text/plain formatter */
if (camel_content_type_is (ct, "text", "plain")) {
g_free (font_family);
g_free (font_size);
g_free ((gchar *) argv[3]);
pango_font_description_free (fd);
goto exit;
} else {
if (!camel_content_type_is (ct, "text", "plain")) {
/* In case of any other content, force use of
* text/plain formatter, because returning FALSE
* for text/x-patch or application/php would show
......@@ -432,6 +425,8 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
g_free ((gchar *) argv[4]);
pango_font_description_free (fd);
if (!success)
goto exit;
} else {
CamelFolder *folder;
const gchar *message_uid;
......
......@@ -5321,134 +5321,136 @@ parse_html_into_blocks (EEditorPage *editor_page,
if (camel_debug ("webkit:editor"))
printf ("\tto_process: '%s'\n", to_process);
if (to_process && !*to_process && processing_last) {
g_free (to_process);
to_process = g_strdup (next_token);
next_token = NULL;
}
if (to_process) {
if (!*to_process && processing_last) {
g_free (to_process);
to_process = g_strdup (next_token);
next_token = NULL;
}
to_insert_end = g_utf8_strlen (to_process, -1);
to_insert_end = g_utf8_strlen (to_process, -1);
if ((with_br = strstr (to_process, "<br>"))) {
if (with_br == to_process)
to_insert_start += 4;
}
if ((with_br = strstr (to_process, "<br>"))) {
if (with_br == to_process)
to_insert_start += 4;
}
if ((citation_start = strstr (to_process, "##CITATION_START"))) {
if (with_br && citation_start == with_br + 4)
to_insert_start += 18; /* + ## */
else if (!with_br && citation_start == to_process)
to_insert_start += 18; /* + ## */
else
to_insert_end -= 18; /* + ## */
has_citation = TRUE;
}
if ((citation_start = strstr (to_process, "##CITATION_START"))) {
if (with_br && citation_start == with_br + 4)
to_insert_start += 18; /* + ## */
else if (!with_br && citation_start == to_process)
to_insert_start += 18; /* + ## */
else
to_insert_end -= 18; /* + ## */
has_citation = TRUE;
}
if ((citation_end = strstr (to_process, "##CITATION_END"))) {
if (citation_end == to_process)
to_insert_start += 16;
else
to_insert_end -= 16; /* + ## */
}
if ((citation_end = strstr (to_process, "##CITATION_END"))) {
if (citation_end == to_process)
to_insert_start += 16;
else
to_insert_end -= 16; /* + ## */
}
/* First BR */
if (with_br && prev_token == html->str)
create_and_append_new_block (
editor_page, parent, block_template, "<br id=\"-x-evo-first-br\">");
/* First BR */
if (with_br && prev_token == html->str)
create_and_append_new_block (
editor_page, parent, block_template, "<br id=\"-x-evo-first-br\">");
if (with_br && citation_start && citation_start == with_br + 4) {
create_and_append_new_block (
editor_page, parent, block_template, "<br>");
if (with_br && citation_start && citation_start == with_br + 4) {
create_and_append_new_block (
editor_page, parent, block_template, "<br>");
append_citation_mark (document, parent, "##CITATION_START##");
} else if (!with_br && citation_start == to_process) {
append_citation_mark (document, parent, "##CITATION_START##");
}
append_citation_mark (document, parent, "##CITATION_START##");
} else if (!with_br && citation_start == to_process) {
append_citation_mark (document, parent, "##CITATION_START##");
}
if (citation_end && citation_end == to_process) {
append_citation_mark (document, parent, "##CITATION_END##");
}
if (citation_end && citation_end == to_process) {
append_citation_mark (document, parent, "##CITATION_END##");
}
if ((to_insert = g_utf8_substring (to_process, to_insert_start, to_insert_end)) && *to_insert) {
gchar *truncated = g_strdup (to_insert);
gchar *rest_to_insert;
if ((to_insert = g_utf8_substring (to_process, to_insert_start, to_insert_end)) && *to_insert) {
gchar *truncated = g_strdup (to_insert);
gchar *rest_to_insert;
if (camel_debug ("webkit:editor"))
printf ("\tto_insert: '%s'\n", to_insert);
if (camel_debug ("webkit:editor"))
printf ("\tto_insert: '%s'\n", to_insert);
if (!*truncated && strlen (to_insert) > 0) {
rest_to_insert = g_strdup (rest);
g_free (truncated);
} else {
rest_to_insert = truncated;
}
if (!*truncated && strlen (to_insert) > 0) {
rest_to_insert = g_strdup (rest);
g_free (truncated);
} else {
rest_to_insert = truncated;
}
replace_selection_markers (&rest_to_insert);
replace_selection_markers (&rest_to_insert);
if (surround_links_with_anchor (rest_to_insert)) {
gboolean is_email_address =
strstr (rest_to_insert, "@") &&
!strstr (rest_to_insert, "://");
if (surround_links_with_anchor (rest_to_insert)) {
gboolean is_email_address =
strstr (rest_to_insert, "@") &&
!strstr (rest_to_insert, "://");
if (is_email_address && !regex_email)