* Fix issue with playlists containing a single quote.

* Ignore bad playlists containing binary data.
This commit is contained in:
Justin Maggard 2010-02-22 22:22:03 +00:00
parent c441187d2a
commit 3934bf4448
2 changed files with 28 additions and 8 deletions

View File

@ -40,7 +40,7 @@ insert_playlist(const char * path, char * name)
{
struct song_metadata plist;
struct stat file;
int items = 0, matches;
int items = 0, matches, ret;
char type[4];
strncpy(type, strrchr(name, '.')+1, 4);
@ -50,11 +50,16 @@ insert_playlist(const char * path, char * name)
DPRINTF(E_WARN, L_SCANNER, "Bad playlist [%s]\n", path);
return -1;
}
while( next_plist_track(&plist, &file, NULL, type) == 0 )
while( (ret = next_plist_track(&plist, &file, NULL, type)) == 0 )
{
items++;
freetags(&plist);
}
if( ret == 2 ) // Bad playlist -- contains binary characters
{
DPRINTF(E_WARN, L_SCANNER, "Bad playlist [%s]\n", path);
return -1;
}
strip_ext(name);
DPRINTF(E_DEBUG, L_SCANNER, "Playlist %s contains %d items\n", name, items);
@ -113,9 +118,8 @@ fill_playlists()
continue;
DPRINTF(E_DEBUG, L_SCANNER, "Scanning playlist \"%s\" [%s]\n", plname, plpath);
sprintf(sql_buf, "SELECT ID from OBJECTS where PARENT_ID = '"MUSIC_PLIST_ID"'"
" and NAME = '%s'", plname);
if( sql_get_int_field(db, sql_buf) <= 0 )
if( sql_get_int_field(db, "SELECT ID from OBJECTS where PARENT_ID = '"MUSIC_PLIST_ID"'"
" and NAME = '%q'", plname) <= 0 )
{
detailID = GetFolderMetadata(plname, NULL, NULL, NULL, NULL);
sql_exec(db, "INSERT into OBJECTS"

View File

@ -50,14 +50,14 @@ start_plist(const char *path, struct song_metadata *psong, struct stat *stat, ch
_utf8bom = 0;
_trackno = 0;
if(strcmp(type, "m3u") == 0)
if(strcasecmp(type, "m3u") == 0)
_next_track = _m3u_next_track;
else if(strcmp(type, "pls") == 0)
else if(strcasecmp(type, "pls") == 0)
_next_track = _pls_next_track;
if(!_next_track)
{
DPRINTF(E_ERROR, L_SCANNER, "Unsupported playlist type <%s>\n", type);
DPRINTF(E_ERROR, L_SCANNER, "Unsupported playlist type <%s> (%s)\n", type, path);
return -1;
}
@ -118,6 +118,14 @@ _m3u_next_track(struct song_metadata *psong, struct stat *stat, char *lang, char
while(p)
{
while(isspace(*p)) p++;
if(!isprint(*p))
{
DPRINTF(E_ERROR, L_SCANNER, "Playlist looks bad (unprintable characters)\n");
fclose(fp);
return 2;
}
if(*p && *p != '#')
{
// check dos format
@ -153,6 +161,14 @@ _pls_next_track(struct song_metadata *psong, struct stat *stat, char *lang, char
while(p)
{
while(isspace(*p)) p++;
if(!isprint(*p))
{
DPRINTF(E_ERROR, L_SCANNER, "Playlist looks bad (unprintable characters)\n");
fclose(fp);
return 2;
}
if(*p && *p != '#')
{
// verify that it's a valid pls playlist