From: David Bremner Date: Tue, 1 Jul 2008 12:23:29 +0000 (+0200) Subject: special case encode / as ~ X-Git-Tag: 0.1~44 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=caadab717359e00b780dc9ea913787329f14f226;p=ikiwiki.git special case encode / as ~ --- diff --git a/Convert/YText.pm b/Convert/YText.pm index 0ce9b48f1..e8ea42abe 100644 --- a/Convert/YText.pm +++ b/Convert/YText.pm @@ -41,10 +41,10 @@ local part of an address: "!#$%&'*+-/=?^_`{|}~". On the other hand, it seems common in practice to block addresses having "%!/|`#&?" in the local part. The idea is to restrict ourselves to basic ASCII alphanumerics, plus a small set of printable ASCII, namely "=_+-~.". -Spaces are replaced with "_", the characters "A-Za-z0-9.\+\-~" encode -as themselves, and everything else is written "=USTR=" where USTR is -the base64 (using "A-Za-z0-9\+\-\." as digits) encoding of the unicode -character code. +Spaces are replaced with "_", "/" with "~", the characters +"A-Za-z0-9.\+\-~" encode as themselves, and everything else is written +"=USTR=" where USTR is the base64 (using "A-Za-z0-9\+\-\." as digits) +encoding of the unicode character code. The characters '+' and '-' are pretty widely used to attach suffixes (although usually only one works on a given mail host). It seems ok to @@ -94,9 +94,11 @@ sub decode_str($){ sub encode_ytext($){ my $str=shift; # "=" we use as an escape, and '_' for space - $str=~ s/([^a-zA-Z0-9+\-~. ])/"=".encode_num(ord($1))."="/ge; + $str=~ s/([^a-zA-Z0-9+\-\/. ])/"=".encode_num(ord($1))."="/ge; + + $str=~ s|/|~|g; $str=~ s/ /_/g; - + return $str; }; @@ -104,7 +106,7 @@ sub decode_ytext($){ my $str = shift; $str=~ s/=([a-zA-Z0-9+\-\.])+=/ decode_str($1)/eg; $str=~ s/_/ /g; - + $str=~ s|~|/|g; return $str; } diff --git a/filters/expand-iki-address.pl b/filters/expand-iki-address.pl index 734a50e37..289aaf615 100644 --- a/filters/expand-iki-address.pl +++ b/filters/expand-iki-address.pl @@ -8,7 +8,7 @@ my $mail = Mail::Internet->new([<>]); my $to = $mail->get('To:'); -if ($to =~ m/$prefix([A-Za-z0-9\.\+\=\-_]+)\@/){ +if ($to =~ m/$prefix([A-Za-z0-9\.\+\=\-_\~]+)\@/){ my $key=$1; my $page=decode_ytext($key); $mail->replace('X-IkiWiki-Page:',$page); diff --git a/filters/test1.eml b/filters/test1.eml index ee0c87ec8..5b1be278e 100644 --- a/filters/test1.eml +++ b/filters/test1.eml @@ -1,29 +1,29 @@ -From bremner@unb.ca Tue Jul 01 08:47:05 2008 +From bremner@unb.ca Tue Jul 01 09:22:23 2008 Return-path: -Envelope-to: bremner-comment-blog=v=posts=v=user_level_NetworkManager_dispatcher@pivot.cs.unb.ca -Delivery-date: Tue, 01 Jul 2008 08:47:05 -0300 +Envelope-to: bremner-comment-blog~posts~filling_in_forms_with_pdftk@pivot.cs.unb.ca +Delivery-date: Tue, 01 Jul 2008 09:22:23 -0300 Received: from [141.44.229.26] (helo=rocinante.cs.unb.ca) by pivot.cs.unb.ca with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) - id 1KDeK9-0006DB-7Y - for bremner-comment-blog=v=posts=v=user_level_NetworkManager_dispatcher@pivot.cs.unb.ca; Tue, 01 Jul 2008 08:47:05 -0300 + id 1KDesI-0006HF-VQ + for bremner-comment-blog~posts~filling_in_forms_with_pdftk@pivot.cs.unb.ca; Tue, 01 Jul 2008 09:22:23 -0300 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.69) (envelope-from ) - id 1KDeJF-0007AA-Hp - for bremner-comment-blog=v=posts=v=user_level_NetworkManager_dispatcher@pivot.cs.unb.ca; Tue, 01 Jul 2008 13:46:09 +0200 + id 1KDerP-0008FX-CM + for bremner-comment-blog~posts~filling_in_forms_with_pdftk@pivot.cs.unb.ca; Tue, 01 Jul 2008 14:21:27 +0200 From: David Bremner Organization: University of New Brunswick, Alpha Centurai Campus -To: bremner-comment-blog=v=posts=v=user_level_NetworkManager_dispatcher@pivot.cs.unb.ca -Subject: this is a test of the postal plugin -Date: Tue, 1 Jul 2008 13:46:09 +0200 +To: bremner-comment-blog~posts~filling_in_forms_with_pdftk@pivot.cs.unb.ca +Subject: this is a test of special casing for / +Date: Tue, 1 Jul 2008 14:21:27 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline -Message-Id: <200807011346.09526.bremner@unb.ca> +Message-Id: <200807011421.27352.bremner@unb.ca> X-Host-Lookup-Failed: Reverse DNS lookup failed for 141.44.229.26 (failed) X-Sender-Verified: bremner@unb.ca