return $str;
}
-sub encode_ytext($){
+sub decode_str($){
my $str=shift;
+ my @chars=split "",$str;
+ my $num=0;
+
+ while (scalar(@chars)>0){
+ my $remainder=index $digit_string,$chars[0];
+
+ # convert this to carp or something
+ die if ($remainder <0);
+ $num=$num << 6;
+ $num+=$remainder;
+ print STDERR "num=$num\n";
+ shift @chars;
+ }
+
+ return chr($num);
+}
+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/ /_/g;
sub decode_ytext($){
my $str = shift;
- $str=~ s/=([a-zA-Z0-9+\-\.])+=/ decode_num($1)/eg;
+ $str=~ s/=([a-zA-Z0-9+\-\.])+=/ decode_str($1)/eg;
+ $str=~ s/_/ /g;
+
+ return $str;
}
=head1 TODO
#!/usr/bin/perl
use Mail::Internet;
-use URI::Escape;
+use Convert::YText 'decode_ytext';
my $prefix="-comment-";
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=uri_unescape($key);
+ my $page=decode_ytext($key);
$mail->replace('X-IkiWiki-Page:',$page);
}
-From: David Bremner <bremner@mailhost.imaginary.org>
-To: bremner-comment-AHNpdGVtYXA@mailhost.imaginary.org
-Subject: I hate your sitemap
-Fcc: %sent-mail
-User-Agent: EMIKO/1.14.1 (Choanoflagellata) FLIM/1.14.9 (=?ISO-8859-4?Q?Go?=
- =?ISO-8859-4?Q?j=F2?=) APEL/10.7 EasyPG/0.0.15 Emacs/22.2
- (i486-pc-linux-gnu) MULE/5.0 (SAKAKI)
-MIME-Version: 1.0 (generated by EMIKO 1.14.1 - "Choanoflagellata")
-Content-Type: text/plain; charset=US-ASCII
+From bremner@unb.ca Tue Jul 01 08:47:05 2008
+Return-path: <bremner@unb.ca>
+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
+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 <bremner@unb.ca>)
+ 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
+Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.69)
+ (envelope-from <bremner@unb.ca>)
+ 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
+From: David Bremner <bremner@unb.ca>
+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
+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>
+X-Host-Lookup-Failed: Reverse DNS lookup failed for 141.44.229.26 (failed)
+X-Sender-Verified: bremner@unb.ca
-It is stupid.
-Why don't you put more work into your blog?