Package: grilo-plugins-0.2
Version: 0.2.14-2
Severity: important
Tags: patch

Dear Maintainer,

grilo plugins crashes taking totem down with it (it depends on some file name I
think)
Upstream bug report: https://bugzilla.gnome.org/show_bug.cgi?id=748604

I rebuilded the package using the 4 patches in the bugreport and grilo don't
crash anymore.

Backtrace:
#0  video_sanitise_string (str=<optimized out>) at grl-local-metadata.c:277
#1  video_display_name_to_metadata (display_name=<optimized out>) at grl-local-
metadata.c:309
#2  video_guess_values_from_display_name (episode=<optimized out>,
season=<optimized out>, date=<optimized out>, showname=<optimized out>,
    title=<optimized out>, display_name=<optimized out>) at grl-local-
metadata.c:327
#3  resolve_video (source=<optimized out>, rs=<optimized out>, flags=<optimized
out>, key=<optimized out>) at grl-local-metadata.c:678
#4  grl_local_metadata_source_resolve (source=0x555557620700,
rs=0x555557da8130) at grl-local-metadata.c:1053
#5  0x00007ffff2fc4612 in ?? () from /usr/lib/x86_64-linux-
gnu/libgrilo-0.2.so.1
#6  0x00007ffff0638b4d in g_main_context_dispatch () from /lib/x86_64-linux-
gnu/libglib-2.0.so.0
#7  0x00007ffff0638f20 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8  0x00007ffff0638fcc in g_main_context_iteration () from /lib/x86_64-linux-
gnu/libglib-2.0.so.0
#9  0x00007ffff2fc101d in grl_wait_for_async_operation_complete () from
/usr/lib/x86_64-linux-gnu/libgrilo-0.2.so.1
#10 0x00007ffff2fc5978 in grl_source_resolve_sync () from /usr/lib/x86_64
-linux-gnu/libgrilo-0.2.so.1
#11 0x00007ffff7b9be14 in ?? () from /usr/lib/libtotem.so.0
#12 0x00007ffff7b9c215 in ?? () from /usr/lib/libtotem.so.0
#13 0x00007ffff2fc1fb7 in ?? () from /usr/lib/x86_64-linux-
gnu/libgrilo-0.2.so.1
#14 0x00007ffff0638b4d in g_main_context_dispatch () from /lib/x86_64-linux-
gnu/libglib-2.0.so.0
#15 0x00007ffff0638f20 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007ffff0638fcc in g_main_context_iteration () from /lib/x86_64-linux-
gnu/libglib-2.0.so.0
#17 0x00007ffff0bfa67c in g_application_run () from /usr/lib/x86_64-linux-
gnu/libgio-2.0.so.0
#18 0x000055555555650b in main ()



-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (900, 'testing'), (450, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=it_IT.utf8, LC_CTYPE=it_IT.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages grilo-plugins-0.2 depends on:
ii  libarchive13             3.1.2-11
ii  libavahi-client3         0.6.31-5
ii  libavahi-common3         0.6.31-5
ii  libavahi-glib1           0.6.31-5
ii  libavahi-gobject0        0.6.31-5
ii  libc6                    2.19-18
ii  libdmapsharing-3.0-2     2.9.30-1
ii  libgdata19               0.16.1-1
ii  libglib2.0-0             2.44.1-1
ii  libgmime-2.6-0           2.6.20-1+b1
ii  libgoa-1.0-0b            3.16.2-1
ii  libgrilo-0.2-1           0.2.12-2
ii  libgstreamer1.0-0        1.4.5-2
ii  libjson-glib-1.0-0       1.0.4-1
ii  liblua5.2-0              5.2.3-1.1
ii  libmediaart-2.0-0        1.9.0-2
ii  liboauth0                1.0.1-1
ii  librest-0.7-0            0.7.93-1
ii  libsoup2.4-1             2.50.0-2
ii  libsqlite3-0             3.8.10.2-1
ii  libtotem-plparser18      3.10.3-1
ii  libtracker-sparql-1.0-0  1.4.0-3
ii  libxml2                  2.9.1+dfsg1-5

Versions of packages grilo-plugins-0.2 recommends:
ii  dleyna-server  0.4.0-1

grilo-plugins-0.2 suggests no packages.
>From a05b159c330a7a65479bba35bc529d0934640627 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steff...@gmail.com>
Date: Tue, 19 May 2015 20:53:28 +0200
Subject: [PATCH 2/2] local-metadata: Fixes to video_sanitise_string non-alnum
 handling

- Extract loop condition into a helper function
- Use g_utf8_get_char to properly convert to unichar
- Be more defensive about g_utf8_find_prev_char returning NULL

https://bugzilla.gnome.org/show_bug.cgi?id=748604
---
 src/local-metadata/grl-local-metadata.c | 39 +++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/local-metadata/grl-local-metadata.c b/src/local-metadata/grl-local-metadata.c
index 45856be..c7f731e 100644
--- a/src/local-metadata/grl-local-metadata.c
+++ b/src/local-metadata/grl-local-metadata.c
@@ -242,6 +242,28 @@ grl_local_metadata_source_set_property (GObject      *object,
 
 /* ======================= Utilities ==================== */
 
+static gboolean
+is_nonalnum (const gchar *str)
+{
+  gunichar uchar;
+
+  if (str == NULL) {
+    return FALSE;
+  }
+
+  uchar = g_utf8_get_char (str);
+
+  if (g_unichar_isalnum (uchar)) {
+    return FALSE;
+  }
+
+  if (uchar == '!' || uchar == '?' || uchar == '.') {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
 static gchar *
 video_sanitise_string (const gchar *str)
 {
@@ -270,22 +292,17 @@ video_sanitise_string (const gchar *str)
   }
 
   if (*line_end != '\0') {
-    line_end = g_utf8_find_prev_char (line, line_end);
-
+    /* After removing substring with blacklisted word, ignore non alpha-numeric
+     * char in the end of the sanitised string */
+    do {
+      line_end = g_utf8_find_prev_char (line, line_end);
+    } while (is_nonalnum (line_end));
 
     /* If everything in the string is blacklisted, just ignore
      * the blackisting logic.
      */
-    if (line_end == NULL)
+    if (line_end == NULL) {
       return g_strdup (str);
-
-    /* After removing substring with blacklisted word, ignore non alpha-numeric
-     * char in the end of the sanitised string */
-    while (g_unichar_isalnum (*line_end) == FALSE &&
-           *line_end != '!' &&
-           *line_end != '?' &&
-           *line_end != '.') {
-      line_end = g_utf8_find_prev_char (line, line_end);
     }
 
     return g_strndup (line, line_end - line);
-- 
2.4.0

>From 63bbbc836cfcb38892b7fdfdac926fd3eb1403da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.cr...@collabora.com>
Date: Tue, 28 Apr 2015 19:46:54 -0400
Subject: [PATCH] local-metadata: Ignore sanitization if the whole filename is
 blacklisted

If the whole filename ends up blacklisted, then just take it as-is.

https://bugzilla.gnome.org/show_bug.cgi?id=748604
---
 src/local-metadata/grl-local-metadata.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/local-metadata/grl-local-metadata.c b/src/local-metadata/grl-local-metadata.c
index adc81f0..45856be 100644
--- a/src/local-metadata/grl-local-metadata.c
+++ b/src/local-metadata/grl-local-metadata.c
@@ -272,6 +272,13 @@ video_sanitise_string (const gchar *str)
   if (*line_end != '\0') {
     line_end = g_utf8_find_prev_char (line, line_end);
 
+
+    /* If everything in the string is blacklisted, just ignore
+     * the blackisting logic.
+     */
+    if (line_end == NULL)
+      return g_strdup (str);
+
     /* After removing substring with blacklisted word, ignore non alpha-numeric
      * char in the end of the sanitised string */
     while (g_unichar_isalnum (*line_end) == FALSE &&
-- 
2.3.6
>From 134a4fbc9f3e70eecd37c07204975b2de16078af Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steff...@gmail.com>
Date: Tue, 19 May 2015 21:00:00 +0200
Subject: [PATCH 1/2] tests: Add another test for a video_sanitise_string()
 crasher

https://bugzilla.gnome.org/show_bug.cgi?id=748604
---
 tests/local-metadata/test_local_metadata.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/local-metadata/test_local_metadata.c b/tests/local-metadata/test_local_metadata.c
index cf9291d..896f65b 100644
--- a/tests/local-metadata/test_local_metadata.c
+++ b/tests/local-metadata/test_local_metadata.c
@@ -166,6 +166,7 @@ test_title_override (void)
     { "Test.mp4", TRUE, "Test" },
     { "Boardwalk.Empire.S04E01.HDTV.x264-2HD.mp4", FALSE, "Boardwalk.Empire.S04E01.HDTV.x264-2HD.mp4" },
     { "wsb.wmv", TRUE, "wsb" },
+    { "[XVID-ITA] Lo Svarione Degli anelli - I DUE PORRI - Clistere.Org - rip by Shella.avi", FALSE, "[XVID-ITA] Lo Svarione Degli anelli - I DUE PORRI - Clistere.Org - rip by Shella.avi" },
   };
 
   registry = grl_registry_get_default ();
-- 
2.4.0

>From 95fb206c1d9f856dc65f3f1a5166f393881607c1 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <had...@hadess.net>
Date: Wed, 29 Apr 2015 13:18:33 +0200
Subject: [PATCH] tests: Add a test for video_sanitise_string() crasher

https://bugzilla.gnome.org/show_bug.cgi?id=748604
---
 tests/local-metadata/test_local_metadata.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/local-metadata/test_local_metadata.c b/tests/local-metadata/test_local_metadata.c
index 6f8d329..cf9291d 100644
--- a/tests/local-metadata/test_local_metadata.c
+++ b/tests/local-metadata/test_local_metadata.c
@@ -164,7 +164,8 @@ test_title_override (void)
     char *expected;
   } filename_tests[] = {
     { "Test.mp4", TRUE, "Test" },
-    { "Boardwalk.Empire.S04E01.HDTV.x264-2HD.mp4", FALSE, "Boardwalk.Empire.S04E01.HDTV.x264-2HD.mp4" }
+    { "Boardwalk.Empire.S04E01.HDTV.x264-2HD.mp4", FALSE, "Boardwalk.Empire.S04E01.HDTV.x264-2HD.mp4" },
+    { "wsb.wmv", TRUE, "wsb" },
   };
 
   registry = grl_registry_get_default ();
-- 
2.3.5

Reply via email to