Composer: Do not send 'Autocrypt' headers larger than 10KB
The Autocrypt specification has this limit. See: https://autocrypt.org/level1.html#id74 Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/375
This commit is contained in:
@ -7016,6 +7016,7 @@ void
|
||||
e_msg_composer_check_autocrypt (EMsgComposer *composer,
|
||||
CamelMimeMessage *original_message)
|
||||
{
|
||||
EAlertBar *alert_bar;
|
||||
gchar *from_email = NULL;
|
||||
gchar *keyid = NULL;
|
||||
gboolean send_public_key = FALSE;
|
||||
@ -7028,6 +7029,10 @@ e_msg_composer_check_autocrypt (EMsgComposer *composer,
|
||||
|
||||
e_msg_composer_remove_header (composer, "Autocrypt");
|
||||
|
||||
alert_bar = e_html_editor_get_alert_bar (e_msg_composer_get_editor (composer));
|
||||
if (alert_bar)
|
||||
e_alert_bar_remove_alert_by_tag (alert_bar, "mail-composer:info-autocrypt-header-too-large");
|
||||
|
||||
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN))) ||
|
||||
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT)))) {
|
||||
/* Autocrypt is about GPG, thus ignore it when the user uses S/MIME */
|
||||
@ -7094,7 +7099,13 @@ e_msg_composer_check_autocrypt (EMsgComposer *composer,
|
||||
g_string_append (value, "; keydata=");
|
||||
g_string_append (value, keydata);
|
||||
|
||||
e_msg_composer_add_header (composer, "Autocrypt", value->str);
|
||||
/* Ignore headers above 10KB in size. See:
|
||||
https://autocrypt.org/level1.html#id74 */
|
||||
if (value->len <= 10240)
|
||||
e_msg_composer_add_header (composer, "Autocrypt", value->str);
|
||||
else
|
||||
e_alert_submit (E_ALERT_SINK (e_msg_composer_get_editor (composer)),
|
||||
"mail-composer:info-autocrypt-header-too-large", from_email, NULL);
|
||||
|
||||
g_string_free (value, TRUE);
|
||||
}
|
||||
|
||||
@ -158,4 +158,9 @@ Detailed error: {0}</_secondary>
|
||||
<_primary>Message Redirection</_primary>
|
||||
<_secondary>This message is a redirection, which allows you to change the recipients, subject and other message attributes, but not the contents of the message.</_secondary>
|
||||
</error>
|
||||
|
||||
<error id="info-autocrypt-header-too-large" type="info">
|
||||
<_primary>Not adding OpenPGP public key into the mail.</_primary>
|
||||
<_secondary>The OpenPGP public key for “{0}” is too large for the transfer.</_secondary>
|
||||
</error>
|
||||
</error-list>
|
||||
|
||||
@ -542,6 +542,27 @@ e_alert_bar_clear (EAlertBar *alert_bar)
|
||||
alert_bar_response_close (alert);
|
||||
}
|
||||
|
||||
gboolean
|
||||
e_alert_bar_remove_alert_by_tag (EAlertBar *alert_bar,
|
||||
const gchar *tag)
|
||||
{
|
||||
GList *link;
|
||||
|
||||
g_return_val_if_fail (E_IS_ALERT_BAR (alert_bar), FALSE);
|
||||
g_return_val_if_fail (tag != NULL, FALSE);
|
||||
|
||||
for (link = g_queue_peek_head_link (&alert_bar->priv->alerts); link; link = g_list_next (link)) {
|
||||
EAlert *alert = link->data;
|
||||
|
||||
if (g_strcmp0 (tag, e_alert_get_tag (alert)) == 0) {
|
||||
alert_bar_response_close (alert);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
gboolean found;
|
||||
EAlert *looking_for;
|
||||
|
||||
@ -65,6 +65,8 @@ GtkWidget * e_alert_bar_new (void);
|
||||
void e_alert_bar_clear (EAlertBar *alert_bar);
|
||||
void e_alert_bar_add_alert (EAlertBar *alert_bar,
|
||||
EAlert *alert);
|
||||
gboolean e_alert_bar_remove_alert_by_tag (EAlertBar *alert_bar,
|
||||
const gchar *tag);
|
||||
gboolean e_alert_bar_close_alert (EAlertBar *alert_bar);
|
||||
void e_alert_bar_submit_alert (EAlertBar *alert_bar,
|
||||
EAlert *alert);
|
||||
|
||||
@ -790,6 +790,14 @@ e_alert_new_array (const gchar *tag,
|
||||
return g_object_new (E_TYPE_ALERT, "tag", tag, "args", args, NULL);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
e_alert_get_tag (EAlert *alert)
|
||||
{
|
||||
g_return_val_if_fail (E_IS_ALERT (alert), NULL);
|
||||
|
||||
return alert->priv->tag;
|
||||
}
|
||||
|
||||
gint
|
||||
e_alert_get_default_response (EAlert *alert)
|
||||
{
|
||||
|
||||
@ -86,6 +86,7 @@ EAlert * e_alert_new_valist (const gchar *tag,
|
||||
va_list va);
|
||||
EAlert * e_alert_new_array (const gchar *tag,
|
||||
GPtrArray *args);
|
||||
const gchar * e_alert_get_tag (EAlert *alert);
|
||||
gint e_alert_get_default_response (EAlert *alert);
|
||||
void e_alert_set_default_response (EAlert *alert,
|
||||
gint response_id);
|
||||
|
||||
@ -2476,3 +2476,21 @@ e_html_editor_clear_alerts (EHTMLEditor *editor)
|
||||
if (editor->priv->alert_bar)
|
||||
e_alert_bar_clear (E_ALERT_BAR (editor->priv->alert_bar));
|
||||
}
|
||||
|
||||
/**
|
||||
* e_html_editor_get_alert_bar:
|
||||
* @editor: an #EHTMLEditor
|
||||
*
|
||||
* Returns an #EAlertBar used by the @editor.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): an #EAlertBar used by the @editor
|
||||
*
|
||||
* Since: 3.50
|
||||
**/
|
||||
EAlertBar *
|
||||
e_html_editor_get_alert_bar (EHTMLEditor *editor)
|
||||
{
|
||||
g_return_val_if_fail (E_IS_HTML_EDITOR (editor), NULL);
|
||||
|
||||
return editor->priv->alert_bar ? E_ALERT_BAR (editor->priv->alert_bar) : NULL;
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include <e-util/e-action-combo-box.h>
|
||||
#include <e-util/e-activity.h>
|
||||
#include <e-util/e-activity-bar.h>
|
||||
#include <e-util/e-alert-bar.h>
|
||||
#include <e-util/e-content-editor.h>
|
||||
#include <e-util/e-focus-tracker.h>
|
||||
|
||||
@ -142,6 +143,7 @@ void e_html_editor_remove_all_cid_parts
|
||||
CamelMimePart * e_html_editor_ref_cid_part (EHTMLEditor *editor,
|
||||
const gchar *cid_uri);
|
||||
void e_html_editor_clear_alerts (EHTMLEditor *editor);
|
||||
EAlertBar * e_html_editor_get_alert_bar (EHTMLEditor *editor);
|
||||
EActionComboBox *
|
||||
e_html_editor_util_new_mode_combobox
|
||||
(void);
|
||||
|
||||
Reference in New Issue
Block a user