Thread View: news.software.misc
3 messages
3 total messages
Started by aclexports
Mon, 06 Nov 2000 00:00
remove unwanted headers ??
Author: aclexports
Date: Mon, 06 Nov 2000 00:00
Date: Mon, 06 Nov 2000 00:00
23 lines
1146 bytes
1146 bytes
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 ? Date: Sender: Newsgroups: Subject: References: These are the only headers I would like to retain. Thanks.
Re: remove unwanted headers ??
Author: 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)
Re: remove unwanted headers ??
Author: J.B. Moreno
Date: Mon, 06 Nov 2000 00:00
Date: Mon, 06 Nov 2000 00:00
33 lines
2268 bytes
2268 bytes
Colin Watson <cjw44@flatline.org.uk> wrote: > aclexports@usa.net wrote: -snip- > >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. There is a bit of ambiguity, that the current folding standard fixes, namely -- how do you maintain more than one space or tab character in the cases where that is important (such as in the Subject)? The answer is simple -- the new standard requires the addition/removal of /just/ the CRLF. So if you have a header that is "blah<sp><sp>blah2" and you want to fold that you can do either "blah<sp><CRLF><sp>blah2" or "blah<CRLF><sp><sp>blah2". -- JBM "Moebius strippers only show you their back side." -- Unknown
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads