#!/usr/bin/perl ## Copyright (C) 2003 Jeremy Andrews ## This is free software; you can redistribute it and/or modify it under the ## terms of the GNU General Public License as published by the Free Software ## Foundation; either version 2 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warrenty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for ## more details. ## ## Version 1.03 (October 08, 2003) ## ## Modified: ## 08/2003 - Jeremy Andrews ## - cleaned up lots of false-positive bugs ## - avoid encoding common html tags ## 10/2003 - JA ## - add Rusty Russel ## 11/2003 - JA ## - switch to absolute paths (otherwise emails link to localhost) ## ## Simple perl script prepares page of emails for kerneltrap posting by: ## - inserting separater at top of file for Drupal ## - inserting horizontal rule at top of file ## - wrapping block of emails with
tags ## - strips email address (replacing with [email blocked]) ## - encodes < and > with < and > repectively ## - urlifying http, telnet and ftp links ## - wraps 'From: Some Body' in ' ## - adds links to KernelTrap interviews, where applicable ## - strips extraneous email headers ## - strips all but first 'To:' header ## - adds standard "related links" block at bottom ## ## Bugs: ## - Doesn't handle html already part of email bodies well ## (tends to encode when it shouldn't, and relinks html links, etc... ## - Doesn't handle From: when name is in quotes ## - Doesn't handle From: when full name is more than two names ## ## If you're good at perl, and can make this script better... Please do! ## I can be reached by email at jeremy@kerneltrap.org ## We only allow one 'To:' header $to=0; ## Begin with for Drupal, add line break and openprint "\n\n"; $urls='(http|telnet|ftp)'; $ltrs = '\w'; $gunk = '/#~:.?+=&%@!\-'; $punc = '.:?\-'; $any = "${ltrs}${gunk}${punc}"; $strip_headers='(^To:|^Sender:|^Cc:|^Organization:|^X-Mailer:|^User-Agent:)'; while (<>) { ## Catch the unwrapped ones in the To: line... s{ ( To: ) ( ((\s*\w+)(-*))+(\w+) ) ( (@)((\w+)(\.))+(\w+) ) }{To: $2}x; ## Try to strip email addresses... s{ ( (\s+)(<*)((\w+)(-*))+(\w+)(@)((\w+)(\.))+(\w+)(>*) ) }{ [email blocked]}x; ## encode < and > if (!(m'
|
||||||
|