TypeError with malformed playlists

Bug #1275525 reported by Matthieu Rakotojaona
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zeya
New
Undecided
Unassigned

Bug Description

Some of my playlists were malformed (ie they did not conform to the spec), and zeya tried to interpret some of its garbage data. Unfortunately it doesn't check for filename correctness, and the os.stat call fails with this error:

```
TypeError: must be encoded string without NULL bytes, not str
```

Here's an easy fix:

```
diff --git a/directory.py b/directory.py
index 069f222..d47fa94 100644
--- a/directory.py
+++ b/directory.py
@@ -134,6 +134,8 @@ class DirectoryBackend(LibraryBackend):
             # previous_db acts as a cache of mtime and metadata, keyed by
             # filename.
             rec_mtime, old_metadata = previous_db.get(filename, (None, None))
+ if (u'\0' in filename):
+ raise ValueError
             file_mtime = os.stat(filename).st_mtime

             if rec_mtime is not None and rec_mtime >= file_mtime:
```

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.