Commits

Christian Ebert committed 22d1196

urlcollector,viewhtmlmsg: give meaningful hint when input message is not raw

Affects urlpager, urlbatcher and viewhtmlmsg.
Kudos to rz at linux-m68k dot org for constructive suggestions.

Comments (0)

Files changed (2)

muttils/urlcollector.py

         if '\0' in s:
             return ''
         msg = _msgfactory(fp)
-        if not msg or not msg['Message-ID']:
+        if not msg:
             fp.seek(0)
             return fp.read()
         # else it's a message or a mailbox
+        if not msg['message-id']:
+            hint = ('make sure input is a raw message,'
+                    ' in mutt: unset pipe_decode')
+            raise util.DeadMan('no message-id found', hint=hint)
         if not msg.get_unixfrom():
             sl = self.msgharvest(msg)
         else: # treat s like a mailbox because it might be one

muttils/viewhtmlmsg.py

                 fp.close()
         except email.Errors.MessageParseError, inst:
             raise util.DeadMan(inst)
-        if not msg or not msg['message-id']:
+        if not msg:
             raise util.DeadMan('input not a message')
+        if not msg['message-id']:
+            hint = ('make sure input is a raw message,'
+                    ' in mutt: unset pipe_decode')
+            raise util.DeadMan('no message-id found', hint=hint)
         htiter = email.Iterators.typed_subpart_iterator(msg, subtype='html')
         try:
             html = htiter.next()