Article View: news.software.misc
Article #2322Re: remove unwanted headers ??
From: Colin Watson
Date: Mon, 06 Nov 2000 00:00
Date: Mon, 06 Nov 2000 00:00
34 lines
2171 bytes
2171 bytes
aclexports@usa.net wrote: >How can I write an algorithm to remove certain headers? > >I have written an algorithm which scans an article line by line from >the top and compares each line against a fixed text (for example >Newsgroups: ) >It it matches, I leave it, if it doesn't, I remove it. >The alogorithm stops processing once it encounters a blank line. > >My problem is linewrapping. >How do I make sure I don't chop off a header that i want to retain ? >Which of these headers have a possibility of linewrapping ? Read RFC822: you can fold headers onto multiple lines wherever linear-white-space is permitted (most places where a space is permitted). Don't hack it for specific headers. Do it properly instead. Anywhere you see a CRLF followed by a space or tab character, unfold it by replacing that pair of characters by a single space or tab character respectively. You can't have a CRLF in the middle of a header unless it's followed by a linear-white-space-character, and you can't have a header name beginning with a space or a tab, so there's no ambiguity. Try not to reinvent the wheel without good reason, as others have done this before. If you're using Perl, for instance, use Mail::Header from the mailtools package. -- Colin Watson [cjw44@flatline.org.uk] "Choose mnemonic identifiers. If you can't remember what mnemonic means, you've got a problem." - perlstyle(1p)
Technical Details
Message-ID:
<8u6qii$cc7$1@riva.ucam.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<3a06d674.1608299@news.alt.net>Show Full Headers
Complete Article Headers
Message-ID: <8u6qii$cc7$1@riva.ucam.org> Subject: Re: remove unwanted headers ?? Date: Mon, 06 Nov 2000 00:00:00 +0000 From: cjw44@flatline.org.uk (Colin Watson) References: <3a06d674.1608299@news.alt.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 690352437 X-Complaints-To: abuse@ntlworld.com X-Trace: news2-win.server.ntlworld.com 973532542 62.253.132.107 (Mon, 06 Nov 2000 17:42:22 GMT) Organization: riva.ucam.org NNTP-Posting-Date: Mon, 06 Nov 2000 17:42:22 GMT Newsgroups: news.software.readers,news.software.nntp,news.software.misc