[rhythmbox] shell-player: check strings are valid utf-8 before emitting dbus signals



commit a5accaf217db9d47bb2facc0af9f5afef3db4425
Author: Jonathan Matthew <jonathan d14n org>
Date:   Mon Feb 22 06:55:07 2010 +1000

    shell-player: check strings are valid utf-8 before emitting dbus signals
    
    Sending invalid utf-8 strings over a dbus connection causes it to
    disconnect, which is generally a bad thing.  See bug 601171.

 shell/rb-shell-player.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/shell/rb-shell-player.c b/shell/rb-shell-player.c
index 6a7e0c8..b963cec 100644
--- a/shell/rb-shell-player.c
+++ b/shell/rb-shell-player.c
@@ -2827,6 +2827,11 @@ rb_shell_player_extra_metadata_cb (RhythmDB *db,
 	/* emit dbus signals for changes with easily marshallable types */
 	switch (G_VALUE_TYPE (metadata)) {
 	case G_TYPE_STRING:
+		/* make sure it's valid utf8, otherwise dbus barfs */
+		if (g_utf8_validate (g_value_get_string (metadata), -1, NULL) == FALSE) {
+			rb_debug ("not emitting extra metadata field %s as value is not valid utf8", field);
+			return;
+		}
 	case G_TYPE_BOOLEAN:
 	case G_TYPE_ULONG:
 	case G_TYPE_UINT64:



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