Artifacts Associated With Ticket b8e82d293b
Ticket change [d4f9f3650b] (rid 180869) by dgp on 2020-03-30 16:38:24:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
% binary decode uuencode [binary encode uuencode -maxlen 3 abc] a*
- foundin initialized to: "all"
- is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "12. ByteArray Object"
- title initialized to: "accepted -maxlen value breaks uuencode round trip"
- type initialized to: "Bug"
Ticket change [949d1a9056] (rid 180870) by dgp on 2020-03-30 17:00:55:
- icomment:
It appears that the constraints of the encoding itself demand that each line have length l where (l - 1) % 4 == 0. A first byte to encode a length, followed by some whole number of 4 byte groups, each encoding 3 bytes. This suggests legal values of -maxlen are 5, 9, 13, 17, ...., 61 (default), 65, ... SOME LIMIT TBD
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [8740b1cde9] (rid 180871) by dgp on 2020-03-30 18:02:07:
- icomment:
Bug was introduced by this checkin https://core.tcl-lang.org/tcl/info/c001d40665 which intended to fix a bug https://core.tcl-lang.org/tcl/info/2152292 which essentially called for a complete rewrite because we were "doing it wrong". Unfortunately, doing it "right" makes an encoding that doesn't roundtrip.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [bb49b1e06f] (rid 180872) by dgp on 2020-03-30 18:20:10:
- assignee changed to: "dkf"
- icomment:
Assigned to dkf just to get attention and input. I'd really like to be talked into the position that a uuencoder ought not have -maxlen or -wrapchar options in the first place, and ours only got them because of an implementation quirk that "forced" options intended for base64 onto uuencode too. Then we could have our option parser continue to tolerate them, but ignore them and always produce standard uuencode format (maxlen == 61, wrapchar == \n).
- login: "dgp"
- mimetype: "text/plain"
Ticket change [f3b027f74a] (rid 180873) by dgp on 2020-03-30 18:22:29:
- icomment:
Some more examples: % set code [binary encode uuencode -maxlen 21 [string repeat abc 10]] /86)C86)C86)C86)C86)C /86)C86)C86)C86)C86)C % binary decode uuencode $code abcabcabcabcabcabcabcabcabcabc % set code [binary encode uuencode -maxlen 20 [string repeat abc 10]] .86)C86)C86)C86)C86( .8V%B8V%B8V%B8V%B8V$ "8F, % binary decode uuencode $code abcabcabcabcabØXØXØXØXØ@Ê
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [01b9e3fd77] (rid 180879) by jan.nijtmans on 2020-03-31 06:17:15:
- icomment:
Suggestion: How about rounding the -maxlen down to the first lower valid value? So -maxlen 6 behaves the same as -maxlen 5, just as -maxlen 8. That restores the round-trip, and still assures that the maximum line length is the supplied value. I think that's better than ignoring the values, however useless they may be. Maxlengths bigger than 77 (the absolute maximum, using length letter ']', should behave the same as -maxlen 77 Just my 2c
- login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [327579379a] (rid 180891) by jan.nijtmans on 2020-03-31 09:08:02:
- icomment:
Correction to the previous comment: The maximum line length is 85, which results in the length character '_'. <pre> % binary encode uuencode -maxlen 86 xxx line length out of range </pre> So, it appears that that's already taken care of.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [601b1dd3b9] (rid 180913) by dgp on 2020-03-31 11:55:49:
- icomment:
Thanks for the review and alternative solution. Will have a look. Meanwhile, can you confirm that allowing -wrapchar to be anything other than \n also breaks roundtrip? The requirement that each "line" of the encoded format must end in the \n character sure appears to be directly embedded in the decoder. Again, these options were not added to the uuencode encode because they were standard or useful. They were just accepted because they came along with the base64 encoder it once shared an implementation with.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [35c276c0a3] (rid 180922) by jan.nijtmans on 2020-03-31 14:30:10:
- icomment:
> Meanwhile, can you confirm that allowing -wrapchar to be anything other than \n also breaks roundtrip? Confirmed. There are two direct checks with '\n' in the code (tclBinary.c lines 2800 and 2837). This means that changing -wrapchar means no roundtrip. Does it really matter? This could simply be documented. Or ... a "-wrapchar" option could be added to uuencode too.... No problem for now, I think, just document it.
- login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [153ad0757f] (rid 180923) by jan.nijtmans on 2020-03-31 14:31:34:
- icomment:
> a "-wrapchar" option could be added to uuencode too.... Of course, I meant "uudecode" here
- login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [8eec4a1cd3] (rid 180924) by dgp on 2020-03-31 14:42:12:
- icomment:
With the decoder we have, the values of -wrapchar that will not break it are those that match the description: A sequence of zero or more characters from the set: \v \f \t \r Followed by zero or one: \n Anything else will break decoding.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [c7f3063a3d] (rid 180925) by dgp on 2020-03-31 14:48:48:
- icomment:
...modulo the existing hackery that pulls in the -wrapchar value as a byte array, so that characters like U+2109 that truncate to become \t also "work" in a way that must be surprising.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [6a7b9029f4] (rid 180929) by dgp on 2020-03-31 15:21:59:
- icomment:
Added value checks to enforce that restriction. Still includes the (mythical?) user out there asking for \r\n With changes in place to keep both options within their valid range, and tests adjusted, I plan to accept this as a fix.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [bc1d4be010] (rid 180935) by dgp on 2020-03-31 15:59:49:
- assignee changed to: "dgp"
- closedate changed to: "2458940.16653975"
- closer changed to: "dgp"
- icomment: "Fix accepted."
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"