1. Travis Shirk
  2. eyeD3

Commits

Travis Shirk  committed b47eeca

Handle invalid date frames, fix issue #13

  • Participants
  • Parent commits 43f5605
  • Branches stable

Comments (0)

Files changed (1)

File src/eyed3/id3/frames.py

View file
     def description(self, txt):
         self._description = txt
 
-    # Data string format: encoding (one byte) + description + "\x00" + text
     def parse(self, data, frame_header):
+        '''Data string format:
+        encoding (one byte) + description + "\x00" + text '''
         # Calling Frame, not TextFrame implementation here since TextFrame
         # does not know about description
         Frame.parse(self, data, frame_header)
         self.date = self.text
         self.encoding = LATIN1_ENCODING
 
+    def parse(self, data, frame_header):
+        super(DateFrame, self).parse(data, frame_header)
+        try:
+            if self.text:
+                _ = core.Date.parse(self.text.encode("latin1"))
+        except ValueError:
+            # Date is invalid, log it and reset.
+            core.parseError(FrameException(u"Invalid date: " + self.text))
+            self.text = u''
+
     @property
     def date(self):
         return core.Date.parse(self.text.encode("latin1")) if self.text \