[mythtv] [BUG+PATCH] MythMusic handling of filenames with backslashes

Corey Mutter mutterc at nc.rr.com
Thu Jan 22 09:22:18 EST 2004


I have a patch against MythMusic 0.13, to fix the metadata handling 
of files whose names/paths contain backslashes. I noticed this in 0.8
but just now got around to investigating. When I ripped my music
collection, I substituted slashes in directory/song names with 
backslashes (like 'AC\DC'), as slash is the one character not allowed
in filenames. MythMusic would never play them.

It turns out that the info goes into the database without having the
backslashes SQL-escaped. This patch fixes that. The conversion of '\'
to '\\' must happen before the conversion of '"' to '\"', or the
instances of '"' will become '\\"' - not good...

Corey

diff -u mythmusic-0.13/metadata.cpp mythmusic/metadata.cpp
--- mythmusic-0.13/metadata.cpp	2004-01-22 09:12:24.000000000 -0500
+++ mythmusic/metadata.cpp	2004-01-22 09:13:52.000000000 -0500
@@ -48,6 +48,7 @@
 {
 
     QString sqlfilename = filename;
+    sqlfilename.replace(QRegExp("\\\\"), QString("\\\\"));
     sqlfilename.replace(QRegExp("\""), QString("\\\""));
 
     QString thequery = QString("UPDATE musicmetadata set "
@@ -74,6 +75,7 @@
     bool retval = false;
 
     QString sqlfilename = filename;
+    sqlfilename.replace(QRegExp("\\\\"), QString("\\\\"));
     sqlfilename.replace(QRegExp("\""), QString("\\\""));
 
     QString thequery = QString("SELECT artist,album,title,genre,year,tracknum,"
@@ -116,12 +118,17 @@
     if (genre == "")
         genre = QObject::tr("Unknown Genre");
 
+    title.replace(QRegExp("\\\\"), QString("\\\\"));
     title.replace(QRegExp("\""), QString("\\\""));
+    artist.replace(QRegExp("\\\\"), QString("\\\\"));
     artist.replace(QRegExp("\""), QString("\\\""));
+    album.replace(QRegExp("\\\\"), QString("\\\\"));
     album.replace(QRegExp("\""), QString("\\\""));
+    genre.replace(QRegExp("\\\\"), QString("\\\\"));
     genre.replace(QRegExp("\""), QString("\\\""));
 
     QString sqlfilename = filename;
+    sqlfilename.replace(QRegExp("\\\\"), QString("\\\\"));
     sqlfilename.replace(QRegExp("\""), QString("\\\""));
 
     QString thequery = QString("INSERT INTO musicmetadata (artist,album,title,"
@@ -228,6 +235,7 @@
         return;
 
     QString sqltitle = title;
+    sqltitle.replace(QRegExp("\\\\"), QString("\\\\"));
     sqltitle.replace(QRegExp("\""), QString("\\\""));
 
     QString thequery = "SELECT artist,album,title,genre,year,tracknum,length,"
@@ -237,12 +245,14 @@
     if (album != "")
     {
         QString temp = album;
+        temp.replace(QRegExp("\\\\"), QString("\\\\"));
         temp.replace(QRegExp("\""), QString("\\\""));
         thequery += " AND album=\"" + temp + "\"";
     }
     if (artist != "")
     {
         QString temp = artist;
+        temp.replace(QRegExp("\\\\"), QString("\\\\"));
         temp.replace(QRegExp("\""), QString("\\\""));
         thequery += " AND artist=\"" + temp + "\"";
     }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040122/c451e496/attachment.pgp


More information about the mythtv-dev mailing list