Re: What to use for displaying MIME?
Grant Edwards <[email protected]>
| Newsgroups | gmane.network.slrn.user |
|---|---|
| Message-ID | <[email protected]> |
On 2007-03-30, Troy Piggins <[email protected]> wrote: First, I should say I was wrong about demime not rendering html and giving no indication of removed attachements. It does indicate the filename and content type of some deleted parts. By running it on the command-line I've figured out that it was trying to use lynx to render HTML (which wasn't installed). Now that lynx is installed, that's working a little better. >> The perl script. (The slang works fine.) Within the first day >> of usage, I ran across a number of signed articles where the >> demime perl script just deleted both the signed message and the >> signature and left nothing. > > Could you provide Message-IDs so I can see what you mean? The problematic posts I have are all from nntp.gmane.org Signed message is deleted: Message-ID: <20070329104148.0c322311@localhost> No filenames or delimeters between text/plain parts: Message-ID: <[email protected]> HTML garbage in output (probably a bug in lynx): Message-ID: <[email protected]> There were a couple more, but now that I have lynx installed, they're working. > Aah. I see. Actually I killfile all text/html only messages. > I know it's ruthless. I used to, but on gmane, they're getting to be rather common, since it's a mirror of mailing lists, and HTML-only mail isn't rare these days. >> What I'm saying is that I couldn't. I tried to bind the >> commands to \e6 and \e7 using your slang file, but it didn't >> work. AFAICT, my copy of slrn always treats escape-6 and >> escape-7 as command prefixes, not commands themselves. I was >> wondering what you did to make \e6 and \e7 work. > > Are you typing <esc>6 etc in group or article mode? It works in > article mode, and group mode I see the command prefix message you > must be seeing. I swear I was typing it article mode. But upon trying it again, it works. I added message() calls to register/unregister functions make it easier to tell. The register/unregister was probably working before and I didn't know it... FWIW, here's the current version of unmime.py ------------------------------8<------------------------------ #!/usr/bin/python import sys,email,subprocess progname = sys.argv[0] sigwarning = False def renderMessage(m): m_type = m.get_content_type() m_name = m.get_filename(None) if m_name: print "[begin attachment: %s]" % m_name if m_type == 'text/plain': print m.get_payload(decode=True) elif m_type == 'text/html': print "[%s: html rendered using w3m]" % progname sys.stdout.flush() p = subprocess.Popen(["w3m","-T","text/html","-dump"], shell=False, stdin=subprocess.PIPE) p.stdin.write(m.get_payload(decode=False)) p.stdin.close() p.wait() else: print " [unhandled content: %s %s]" % (m_type,m_name) if m_name: print "[end attachment: %s]" % m_name def handleAlternative(m): parts = m.get_payload() for part in parts: if part.get_content_type() == 'text/plain': renderMessage(part) return for part in parts: if part.get_content_type() == 'text/html': renderMessage(part) return print "[%s: didn't find any recognizable alternatives, so dumping everything]" % progname handleMixed(m) def handleSigned(m): for part in m.get_payload(): part_type = part.get_content_type() if 'text/plain' in part_type: if sigwarning: print "[%s: SIGNATURE NOT VERIFIED]\n" % progname renderMessage(part) if sigwarning: print "[%s: SIGNATURE NOT VERIFIED]\n" % progname elif 'application/pgp-signature' in part_type: pass else: print "[%s multipart/signed part unhandled: %s]" % (progname,part_type) def handleMixed(m): for part in m.get_payload(): handleMessage(part) def handleMultipart(m): content_type = m.get_content_subtype() if content_type == 'alternative': handleAlternative(m) elif content_type == 'mixed': handleMixed(m) elif content_type == 'signed': handleSigned(m) else: print "unknown multipart content type:",content_type def handleMessage(m): if m.is_multipart(): handleMultipart(m) else: renderMessage(m) msg = email.message_from_file(sys.stdin) for line in msg.as_string().split('\n'): if not line.startswith('Content-Type:'): print line if line == '': break handleMessage(msg) ------------------------------8<------------------------------ -- Grant Edwards grante Yow! Actually, what at I'd like is a little toy visi.com spaceship!! ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV