hi
I am using freevo 1.7.0 , in a Debian Etch box.
I have huge problems accessing a data CD that I myself burnt
some time ago.
The problem is, when I prepared that CD, my locale encoding was set
to it_IT.ISO-8859-1 , that is, latin-1 encoding ;
that was the standard in Debian Sarge ; but in Debian Etch,
the standard is to use UTF-8 encoding.
So that CD has all accented characters in filenames encoded in latin-1
and they are wrong.
This CD crashes freevo in many many ways ; I tried
starting Freevo with it_IT.ISO-8859-1 locale, but it did not work either.
So I tried debugging freevo, and I could identify one crash point
and fix it (see patch), but could not fix all.
Here is the explanation of why vfs.py crashes;
consider those variables as they are set in vfs.py when accessing my CD:
>>> media.id
u'2005072211462600lug_05'
>>> type(media.id)
<type 'unicode'>
>>> directory
'qu\xe9'
>>> type(directory)
<type 'str'>
>>> media.id+directory
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 2: ordinal
not in range(128)
The problem is this: the media.id object is an
unicode python object, whereas the directory is a raw string containing
latin-1 stuff : when concatenating, Python tries to promote
the directory to Unicode, and fails.
My patch is a workaround to the problem: indeed
>>> str(media.id)+directory
'2005072211462600lug_05qu\xe9'
works fine.
My attached patch is a workaround, but is not the correct way
to act. The correct way is to avoid using the Unicode python type
for data that may eventually be used for filenames.
Using the Unicode python type for file&directory names is a bad bad idea:
it will crash whenever it will be presented with a filename
with invalid chars in it.
BTW my patch does not fix all the problems: another crash I got
was
File "/usr/lib/python2.4/site-packages/freevo/item.py", line 288, in set_url
audiocover = util.getimage(os.path.dirname(self.filename)+'/'+filemask)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 38-39:
unexpected end of data
So, dow do we fix those problems?
For example, where in mmpython should we intervene to avoid
that media.id be an Unicode string?
a.
--
Andrea Mennucc
"The EULA sounds like it was written by a team of lawyers who want to tell
me what I can't do, and the GPL sounds like it was written by a human
being who wants me to know what I can do."
Anonymous, http://www.securityfocus.com/columnists/420
--- /usr/lib/python2.4/site-packages/freevo/util/vfs.py.orig 2007-04-30 20:40:26.000000000 +0200
+++ /usr/lib/python2.4/site-packages/freevo/util/vfs.py 2007-05-01 19:50:40.000000000 +0200
@@ -72,7 +72,7 @@
for media in config.REMOVABLE_MEDIA:
if directory.startswith(media.mountdir):
directory = directory[len(media.mountdir):]
- return '%s/disc/%s%s' % (config.OVERLAY_DIR, media.id, directory)
+ return config.OVERLAY_DIR+'/disc/'+str(media.id)+directory
return config.OVERLAY_DIR + directory
@@ -244,7 +244,7 @@
id = name[:name.find('/')]
name = name[name.find('/')+1:]
for media in config.REMOVABLE_MEDIA:
- if media.id == id:
+ if str(media.id) == str(id):
name = os.path.join(media.mountdir, name)
return name
return name
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel