leosongwei / mutagen

Automatically exported from code.google.com/p/mutagen
GNU General Public License v2.0
0 stars 0 forks source link

Mutagen fails on ID3v2.4 tags with footer #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From http://code.google.com/p/quodlibet/issues/detail?id=200 :

There is a bug in mutagen's penantic check on ID3v2 header flags. This
check always fails on ID3v2.4 tags with a tag footer.

In id3.py, there is the following bit of code which intends to disallow
flag 0x10 (footer present) for ID3v2.3. However, the code effectively also
disallows this flag for ID3v2.4 flags:

  if (2,4,0) <= self.version and (flags & 0x0f):
    raise ValueError("'%s' has invalid flags %#02x" % (fn, flags))
  elif (2,3,0) <= self.version and (flags & 0x1f):
    raise ValueError("'%s' has invalid flags %#02x" % (fn, flags))

I suggest chaning it into:
  if (2,4,0) <= self.version:
    if (flags & 0x0f):
      raise ValueError("'%s' has invalid flags %#02x" % (fn, flags))
  elif (2,3,0) <= self.version:
    if (flags & 0x1f):
      raise ValueError("'%s' has invalid flags %#02x" % (fn, flags))

Error message:
>>> f = mutagen.File('01_preludium.mp3')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/mutagen/__init__.py", line 199, in
File
    if score > 0: return Kind(filename)
  File "/usr/lib/python2.5/site-packages/mutagen/__init__.py", line 74, in
__init__
    self.load(filename, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/mutagen/id3.py", line 1945, in load
    try: self.tags = ID3(filename, **kwargs)
  File "/usr/lib/python2.5/site-packages/mutagen/id3.py", line 74, in __init__
    super(ID3, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/mutagen/_util.py", line 103, in
__init__
    super(DictProxy, self).__init__(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/mutagen/__init__.py", line 38, in
__init__
    self.load(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/mutagen/id3.py", line 113, in load
    self.__load_header()
  File "/usr/lib/python2.5/site-packages/mutagen/id3.py", line 220, in
__load_header
    raise ValueError("'%s' has invalid flags %#02x" % (fn, flags))
ValueError: '01_id3v22_preludium.mp3' has invalid flags 0x90

Original issue reported on code.google.com by steven.strobe.cc@gmail.com on 18 Jun 2009 at 5:06

GoogleCodeExporter commented 9 years ago

Original comment by joe.wreschnig@gmail.com on 24 Jun 2009 at 9:05

GoogleCodeExporter commented 9 years ago

Original comment by joe.wreschnig@gmail.com on 24 Jun 2009 at 9:05

GoogleCodeExporter commented 9 years ago
Fixed in r34, however we still don't have a real-world test.

Original comment by joe.wreschnig@gmail.com on 5 Jul 2009 at 1:35