* Morita Sho ([EMAIL PROTECTED]) wrote:
> >Thanks for the patch, but I think it would be preferable to use awk or
> >sed instead of perl...
> >
> >Anyways, this is something we ought to fix.
> 
> Yes, I agree to you.
> 
> I have challenged to write a percent-encoding code without perl.
> A patch I have attached is works using sed instead of perl.
> (Additionally, seq, printf and tr is used. but these are included in 
> coreutils
> package)
> 
> I guess that sed have no functionality similar to "pack" in perl.
> Therefore, my approach is making pattern like following first:
> s/\x00/%00/g
> s/\x01/%01/g
> s/\x02/%02/g
> s/\x03/%03/g
> s/\x04/%04/g
> ...[snip]...
> s/\xFC/%FC/g
> s/\xFD/%FD/g
> s/\xFE/%FE/g
> s/\xFF/%FF/g
> 
> And then, apply this pattern to string that should be percent-encoded using 
> sed.
> I explain shortly about my patch:
> The pattern "s/%/%25/g" is placed the top of patterns.
> The pattern "s/\x5C/%5C/g" (substitute "\" to %5C) will occurs an error
> "Trailing backslash", but I can't find what is wrong.
> So I have simply changed it to "s/\\/%5C/g".
> The pattern "s/\[/%5B/g" and "s/\^/%5E/g" is same reason.
> 
> "1!{s/^/%0A/g}" and "tr -d '\n'" is a workaround for substitute 0x0A ("\n",
> newline character) to %0A.
> 
> 
> I have confirmed this code is works fine on bash, dash and zsh.
> 
> However, this code is longer and complex than code that used perl.
> It might be possible to write more smart code, but I have no skill to do 
> it...

Wow, the perl is looking better. I'm not proficient enough in sed and
awk to tell you if there's a better way to do this. I'll apply the
perl code for now. 


-- 
Eric Dorland <[EMAIL PROTECTED]>
ICQ: #61138586, Jabber: [EMAIL PROTECTED]
1024D/16D970C6 097C 4861 9934 27A0 8E1C  2B0A 61E9 8ECF 16D9 70C6

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d- s++: a-- C+++ UL+++ P++ L++ E++ W++ N+ o K- w+ 
O? M++ V-- PS+ PE Y+ PGP++ t++ 5++ X+ R tv++ b+++ DI+ D+ 
G e h! r- y+ 
------END GEEK CODE BLOCK------

Attachment: signature.asc
Description: Digital signature

Reply via email to