[PATCH parole] Add missing escaping in audiobox

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH parole] Add missing escaping in audiobox

Simon Marchi
When playing a file with an ampersand in it, I noticed this kind of
warnings:

(parole:16594): Gtk-WARNING **: Failed to set text '<span color='#F4F4F4'><b><big>test & test.mp3</big></b></span>' from markup due to error parsing markup: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity - escape ampersand as &amp;

And indeed, the function parole_player_media_tag_cb fails to escape the
filename.  I changed the calls to g_strdup_printf to
g_markup_printf_escaped.  The warnings have disappeared, and the
audiobox now shows the filename whereas it would show "Unknown song"
before.
---
 src/parole-player.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/parole-player.c b/src/parole-player.c
index 6baddb3..3b39974 100644
--- a/src/parole-player.c
+++ b/src/parole-player.c
@@ -1912,13 +1912,13 @@ parole_player_media_tag_cb (ParoleGst *gst, const ParoleStream *stream, ParolePl
             if ( filename )
             {
                 gtk_window_set_title (GTK_WINDOW (player->priv->window), filename);
-                gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title), g_strdup_printf("<span color='#F4F4F4'><b><big>%s</big></b></span>", filename));
+                gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title), g_markup_printf_escaped("<span color='#F4F4F4'><b><big>%s</big></b></span>", filename));
                 g_free (filename);
             }
             else
             {
                 gtk_window_set_title (GTK_WINDOW (player->priv->window), _("Parole Media Player"));
-                gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title), g_strdup_printf("<span color='#F4F4F4'><b><big>%s</big></b></span>", _("Unknown Song")));
+                gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title), g_markup_printf_escaped("<span color='#F4F4F4'><b><big>%s</big></b></span>", _("Unknown Song")));
             }
         }
         g_free(uri);
@@ -1934,7 +1934,7 @@ parole_player_media_tag_cb (ParoleGst *gst, const ParoleStream *stream, ParolePl
         }
 
         else
-            gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_album), g_strdup_printf("<big><span color='#BBBBBB'><i>%s</i></span> <span color='#F4F4F4'>%s</span></big>", _("on"), _("Unknown Album")));
+            gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_album), g_markup_printf_escaped("<big><span color='#BBBBBB'><i>%s</i></span> <span color='#F4F4F4'>%s</span></big>", _("on"), _("Unknown Album")));
 
         if (year)
             g_free (year);
@@ -1945,7 +1945,7 @@ parole_player_media_tag_cb (ParoleGst *gst, const ParoleStream *stream, ParolePl
             g_free (artist);
         }
         else
-            gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_artist), g_strdup_printf("<big><span color='#BBBBBB'><i>%s</i></span> <span color='#F4F4F4'>%s</span></big>", _("by"), _("Unknown Artist")));
+            gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_artist), g_markup_printf_escaped("<big><span color='#BBBBBB'><i>%s</i></span> <span color='#F4F4F4'>%s</span></big>", _("by"), _("Unknown Artist")));
 
         image = parole_stream_get_image(G_OBJECT(stream));
         if (image)
--
2.12.1

_______________________________________________
Xfce4-dev mailing list
[hidden email]
https://mail.xfce.org/mailman/listinfo/xfce4-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH parole] Add missing escaping in audiobox

Simon Marchi
On 2017-03-26 16:27, Simon Marchi wrote:

> When playing a file with an ampersand in it, I noticed this kind of
> warnings:
>
> (parole:16594): Gtk-WARNING **: Failed to set text '<span
> color='#F4F4F4'><b><big>test & test.mp3</big></b></span>' from markup
> due to error parsing markup: Error on line 1: Entity did not end with
> a semicolon; most likely you used an ampersand character without
> intending to start an entity - escape ampersand as &amp;
>
> And indeed, the function parole_player_media_tag_cb fails to escape the
> filename.  I changed the calls to g_strdup_printf to
> g_markup_printf_escaped.  The warnings have disappeared, and the
> audiobox now shows the filename whereas it would show "Unknown song"
> before.
> ---
>  src/parole-player.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/parole-player.c b/src/parole-player.c
> index 6baddb3..3b39974 100644
> --- a/src/parole-player.c
> +++ b/src/parole-player.c
> @@ -1912,13 +1912,13 @@ parole_player_media_tag_cb (ParoleGst *gst,
> const ParoleStream *stream, ParolePl
>              if ( filename )
>              {
>                  gtk_window_set_title (GTK_WINDOW
> (player->priv->window), filename);
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_strdup_printf("<span color='#F4F4F4'><b><big>%s</big></b></span>",
> filename));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_markup_printf_escaped("<span
> color='#F4F4F4'><b><big>%s</big></b></span>", filename));
>                  g_free (filename);
>              }
>              else
>              {
>                  gtk_window_set_title (GTK_WINDOW
> (player->priv->window), _("Parole Media Player"));
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_strdup_printf("<span color='#F4F4F4'><b><big>%s</big></b></span>",
> _("Unknown Song")));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_markup_printf_escaped("<span
> color='#F4F4F4'><b><big>%s</big></b></span>", _("Unknown Song")));
>              }
>          }
>          g_free(uri);
> @@ -1934,7 +1934,7 @@ parole_player_media_tag_cb (ParoleGst *gst,
> const ParoleStream *stream, ParolePl
>          }
>
>          else
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_album),
> g_strdup_printf("<big><span color='#BBBBBB'><i>%s</i></span> <span
> color='#F4F4F4'>%s</span></big>", _("on"), _("Unknown Album")));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_album),
> g_markup_printf_escaped("<big><span color='#BBBBBB'><i>%s</i></span>
> <span color='#F4F4F4'>%s</span></big>", _("on"), _("Unknown Album")));
>
>          if (year)
>              g_free (year);
> @@ -1945,7 +1945,7 @@ parole_player_media_tag_cb (ParoleGst *gst,
> const ParoleStream *stream, ParolePl
>              g_free (artist);
>          }
>          else
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_artist),
> g_strdup_printf("<big><span color='#BBBBBB'><i>%s</i></span> <span
> color='#F4F4F4'>%s</span></big>", _("by"), _("Unknown Artist")));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_artist),
> g_markup_printf_escaped("<big><span color='#BBBBBB'><i>%s</i></span>
> <span color='#F4F4F4'>%s</span></big>", _("by"), _("Unknown
> Artist")));
>
>          image = parole_stream_get_image(G_OBJECT(stream));
>          if (image)

Ping.
_______________________________________________
Xfce4-dev mailing list
[hidden email]
https://mail.xfce.org/mailman/listinfo/xfce4-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH parole] Add missing escaping in audiobox

Sean Davis-6
Hi Simon!

Sorry for the delay.  The patch works as expected and has been pushed here:


Thanks!
Sean

On Sun, Apr 9, 2017 at 10:22 PM Simon Marchi <[hidden email]> wrote:
On 2017-03-26 16:27, Simon Marchi wrote:
> When playing a file with an ampersand in it, I noticed this kind of
> warnings:
>
> (parole:16594): Gtk-WARNING **: Failed to set text '<span
> color='#F4F4F4'><b><big>test & test.mp3</big></b></span>' from markup
> due to error parsing markup: Error on line 1: Entity did not end with
> a semicolon; most likely you used an ampersand character without
> intending to start an entity - escape ampersand as &amp;
>
> And indeed, the function parole_player_media_tag_cb fails to escape the
> filename.  I changed the calls to g_strdup_printf to
> g_markup_printf_escaped.  The warnings have disappeared, and the
> audiobox now shows the filename whereas it would show "Unknown song"
> before.
> ---
>  src/parole-player.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/parole-player.c b/src/parole-player.c
> index 6baddb3..3b39974 100644
> --- a/src/parole-player.c
> +++ b/src/parole-player.c
> @@ -1912,13 +1912,13 @@ parole_player_media_tag_cb (ParoleGst *gst,
> const ParoleStream *stream, ParolePl
>              if ( filename )
>              {
>                  gtk_window_set_title (GTK_WINDOW
> (player->priv->window), filename);
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_strdup_printf("<span color='#F4F4F4'><b><big>%s</big></b></span>",
> filename));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_markup_printf_escaped("<span
> color='#F4F4F4'><b><big>%s</big></b></span>", filename));
>                  g_free (filename);
>              }
>              else
>              {
>                  gtk_window_set_title (GTK_WINDOW
> (player->priv->window), _("Parole Media Player"));
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_strdup_printf("<span color='#F4F4F4'><b><big>%s</big></b></span>",
> _("Unknown Song")));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_title),
> g_markup_printf_escaped("<span
> color='#F4F4F4'><b><big>%s</big></b></span>", _("Unknown Song")));
>              }
>          }
>          g_free(uri);
> @@ -1934,7 +1934,7 @@ parole_player_media_tag_cb (ParoleGst *gst,
> const ParoleStream *stream, ParolePl
>          }
>
>          else
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_album),
> g_strdup_printf("<big><span color='#BBBBBB'><i>%s</i></span> <span
> color='#F4F4F4'>%s</span></big>", _("on"), _("Unknown Album")));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_album),
> g_markup_printf_escaped("<big><span color='#BBBBBB'><i>%s</i></span>
> <span color='#F4F4F4'>%s</span></big>", _("on"), _("Unknown Album")));
>
>          if (year)
>              g_free (year);
> @@ -1945,7 +1945,7 @@ parole_player_media_tag_cb (ParoleGst *gst,
> const ParoleStream *stream, ParolePl
>              g_free (artist);
>          }
>          else
> -
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_artist),
> g_strdup_printf("<big><span color='#BBBBBB'><i>%s</i></span> <span
> color='#F4F4F4'>%s</span></big>", _("by"), _("Unknown Artist")));
> +
> gtk_label_set_markup(GTK_LABEL(player->priv->audiobox_artist),
> g_markup_printf_escaped("<big><span color='#BBBBBB'><i>%s</i></span>
> <span color='#F4F4F4'>%s</span></big>", _("by"), _("Unknown
> Artist")));
>
>          image = parole_stream_get_image(G_OBJECT(stream));
>          if (image)

Ping.
_______________________________________________
Xfce4-dev mailing list
[hidden email]
https://mail.xfce.org/mailman/listinfo/xfce4-dev

_______________________________________________
Xfce4-dev mailing list
[hidden email]
https://mail.xfce.org/mailman/listinfo/xfce4-dev
Loading...