mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
$decode(&binvar,bm) lengths 1-3,5-6,9 without padding char decode to $null string.

This bug does not happen in v6.35, but does happen in v7.49 and 7.52.

Because $hotp can decode all lengths of base32 strings which don't contain the '=' padding character, I tested $decode to see if it could also do the same with decoding similar base32 strings, and it can. But in testing mime, I found that $decode doesn't correctly handle short lengths of mime text without the padding character, but only if they're contained in a &binvar. If the mime string in a &binvar is length 1-3,5-6,9 it decodes to the $null string, but if that same string is in a %variable it decodes correctly.

Code:
//var %i 1 , %mode m , %b $encode($str(~,99),%mode) | while (%i isnum 1-99) { var %a $left(%b,%i) | bset -tc &v 1 %a | noop $decode(&v,b %mode) | if ($bvar(&v,1-).text != $decode(%a,%mode)) echo -ag %i / binvar $v1 vs text $v2 string= %a | inc %i }



Some of these lengths are typically not created by $encode because the longer encoded strings cause some lengths to be skipped. However of the lengths created by $encode, lengths 1,2,4 do not decode to the original string when the mime text does not contain the padding character and is contained in a &binvar, but is correctly handed if it's in a %variable.

Code:
//var %i 1 , %mode m | while (%i isnum 1-19) { var %text $str(~,%i) , %encode $encode(%text,%mode) , %encode2 $remove(%encode,=,`) , %decode $decode(%encode2,%mode) | bset -tc &v 1 %encode2 | noop $decode(&v,b %mode) | if ( ($bvar(&v,1-).text != %text) || (%decode != %text) || (!$bvar(&v,0)) ) echo -ag length %i binvar $bvar(&v,1-).text vs text %decode vs original %text encoded $+ $len(%encode2) $+ = %encode2 $decode(%encode,%mode)  | inc %i }


Joined: Dec 2002
Posts: 5,421
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,421
Thanks, it looks like this issue was fixed with the change in item 32 in beta.txt. If it is still an issue, please let me know.


Link Copied to Clipboard