<i>binary decode base64 breaks with trailing spaces</i> status still Open with 4 other changes
by
.
D 2012-10-18T09:03:57
J icomment I\shit\sthis\sproblem\sin\s8.6b3,\sand\sit\shad\svery\sserious\sconsequences\sfor\smy\sapplication,\sso\sI\sfixed\sit\sproperly.\n\nI\scan't\sfigure\sout\show\sto\sattach\sa\sfile\shere,\sso\sI\sput\sit\son\sthe\sTcl\sWiki:\shttp://wiki.tcl.tk/tcl8.6b3-base64decode.patch\s.\s\sSomebody\splease\smove\sthat\sfile\shere\sas\sa\sreal\sattachment\sand\sdelete\sthat\swiki\spage.\n\nThis\spatch\stidies\sup\sthe\ssemantics\sfor\sthe\scut\svariable,\sand\sit\sdoes\sso\sby\smaking\sthe\sbsae64\sdecoder\sa\sbit\smore\sstrict.\s\sOnly\sone\sor\stwo\s='s\sare\sallowed,\sand\sthey\smust\sbe\sat\sthe\send\sof\sthe\sfinal\sblock.\s\sTherefore\scut\scan\sonly\sbe\snonzero\sat\sor\safter\sthe\sfinal\sblock,\sand\sit\scan\sonly\sgo\sup\sto\stwo,\ssince\sat\smost\stwo\sbytes\scan\sbe\sstripped\sfrom\sthe\soutput\s(there\sare\sonly\sthree\soutput\sbytes\sper\sblock).\s\sBut\sif\sthere's\swhitespace\sfollowing\sthe\sfinal\sblock,\sthree\sis\sadded\sto\scut\sto\sstrip\sthe\sentire\sdummy\sblock\sthat\sthe\swhitespace\swould\sotherwise\sgenerate.\n\nThis\spatch\sadds\ssome\scases\sto\sbinary.test\sto\sconfirm\sthat\sit's\sworking\sas\sdesigned.\s\sIt\salso\sadds\sa\slot\sof\scomments\sto\sthe\sdecode\sfunction\sto\sexplain\swhat\sit's\sdoing.\n\nI'd\smake\sthe\scode\seven\sstricter,\sspecifically\sI'd\srequire\sthat\sthe\sinput\sbe\sa\smultiple\sof\sfour\scharacters\sin\slength,\sbut\sthat\sbreaks\sexisting\scases\sin\sthe\stest\ssuite.\s\sInstead\sI\sadded\scomments\sto\sdocument\sthe\scurrent\sbehavior\sregarding\sincomplete\sblocks.\s\sWith\sor\swithout\smy\spatch\sapplied,\sthe\sbehavior\sis:\n\n-\sIf\sthe\sinput\slength\s(not\scounting\swhitespace)\sis\s4n+1,\swhere\sn\sis\san\sinteger,\sthe\slast\scharacter\sis\signored.\n-\sIf\sthe\sinput\slength\sis\s4n+2,\stwo\s='s\sare\sassumed\sat\send\sof\sinput.\n-\sIf\sthe\sinput\slength\sis\s4n+3,\sone\s=\sis\sassumed\sat\send\sof\sinput.\n-\sIf\sthe\sinput\slength\sis\s4n,\sno\smassaging\sis\snecessary.\n\nWithout\smy\spatch,\strailing\swhitespace\scauses\sthe\sfinal\soutput\scharacter\sto\sbe\sdropped.\n\n
J login andygoth
J mimetype text/plain
J username andygoth
K 3033307fffffffffffffffffffffffffffffffff
U andygoth
Z 600281cfcb660d200dc23c639514f7f6