core: Shorten title first, then mangle chars
authorJens Georg <mail@jensge.org>
Thu, 13 Oct 2011 08:56:06 +0000 (10:56 +0200)
committerJens Georg <mail@jensge.org>
Thu, 13 Oct 2011 09:16:56 +0000 (11:16 +0200)
src/rygel/rygel-item-creator.vala

index 5e98ee6..de25154 100644 (file)
@@ -373,13 +373,14 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
     }
 
     private string mangle_title (string title) throws Error {
-        var mangled = this.title_regex.replace_literal (title,
-                                                 -1,
-                                                 0,
-                                                 "_",
-                                                 RegexMatchFlags.NOTEMPTY);
-
-        return mangled.substring (0, int.min (mangled.length, 240));
+        var mangled = title.substring (0, int.min (title.length, 240));
+        mangled = this.title_regex.replace_literal (mangled,
+                                                    -1,
+                                                    0,
+                                                    "_",
+                                                    RegexMatchFlags.NOTEMPTY);
+
+        return mangled;
     }
 
     private async string create_uri (WritableContainer container, string title)