[network-manager-applet/lr/gtk4-part1: 2/6] nma/pkcs11-cert-chooser: escape mnemonic in cert/key title



commit b09edbf8a3c98517e7f70803ae02df11a99ec570
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Fri Feb 15 11:20:31 2019 +0100

    nma/pkcs11-cert-chooser: escape mnemonic in cert/key title
    
    In an unlikely event someone picks a title with an underscore in it,
    like I've just done in a test case.

 src/libnma/nma-pkcs11-cert-chooser.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/libnma/nma-pkcs11-cert-chooser.c b/src/libnma/nma-pkcs11-cert-chooser.c
index 927b13cf..9e065834 100644
--- a/src/libnma/nma-pkcs11-cert-chooser.c
+++ b/src/libnma/nma-pkcs11-cert-chooser.c
@@ -371,17 +371,23 @@ static void
 set_title (NMACertChooser *cert_chooser, const gchar *title)
 {
        NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+       gchar *mnemonic_escaped;
        gchar *text;
+       char **split;
+
+       split = g_strsplit (title, "_", -1);
+       mnemonic_escaped = g_strjoinv("__", split);
+       g_strfreev (split);
 
        text = g_strdup_printf (_("Choose a key for %s Certificate"), title);
        nma_cert_chooser_button_set_title (NMA_CERT_CHOOSER_BUTTON (priv->key_button), text);
        g_free (text);
 
-       text = g_strdup_printf (_("%s private _key"), title);
+       text = g_strdup_printf (_("%s private _key"), mnemonic_escaped);
        gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_button_label), text);
        g_free (text);
 
-       text = g_strdup_printf (_("%s key _password"), title);
+       text = g_strdup_printf (_("%s key _password"), mnemonic_escaped);
        gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->key_password_label), text);
        g_free (text);
 
@@ -389,13 +395,15 @@ set_title (NMACertChooser *cert_chooser, const gchar *title)
        nma_cert_chooser_button_set_title (NMA_CERT_CHOOSER_BUTTON (priv->cert_button), text);
        g_free (text);
 
-       text = g_strdup_printf (_("%s _certificate"), title);
+       text = g_strdup_printf (_("%s _certificate"), mnemonic_escaped);
        gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->cert_button_label), text);
        g_free (text);
 
-       text = g_strdup_printf (_("%s certificate _password"), title);
+       text = g_strdup_printf (_("%s certificate _password"), mnemonic_escaped);
        gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->cert_password_label), text);
        g_free (text);
+
+       g_free (mnemonic_escaped);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]