summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--doc/binary.n11
-rw-r--r--generic/tclBinary.c9
-rw-r--r--tests/binary.test10
4 files changed, 24 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 5aa4aa3..0454c6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-15 Alexandre Ferrieux <ferrieux@users.sourceforge.net>
+
+ * generic/tclBinary.c: Fix [Bug 2380293]. Redefine non-strict
+ * doc/binary.n: decoding to ignore only whitespace.
+ * tests/binary.test:
+
2008-12-15 Don Porter <dgp@users.sourceforge.net>
TIP #338 IMPLEMENTATION
diff --git a/doc/binary.n b/doc/binary.n
index c5e8a4e..e038fb5 100644
--- a/doc/binary.n
+++ b/doc/binary.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: binary.n,v 1.43 2008/10/14 22:30:59 dkf Exp $
+'\" RCS: @(#) $Id: binary.n,v 1.44 2008/12/15 17:11:33 ferrieux Exp $
'\"
.so man.macros
.TH binary n 8.0 Tcl "Tcl Built-In Commands"
@@ -73,8 +73,7 @@ During decoding, the following options are supported:
.TP
\fB\-strict\fR
.
-Instructs the decoder to throw an error if it encounters any characters that
-are not strictly part of the encoding itself. Otherwise it ignores them.
+Instructs the decoder to throw an error if it encounters whitespace characters. Otherwise it ignores them.
.RE
.TP
\fBhex\fR
@@ -88,8 +87,7 @@ options are supported:
.TP
\fB\-strict\fR
.
-Instructs the decoder to throw an error if it encounters any characters that
-are not strictly part of the encoding itself. Otherwise it ignores them.
+Instructs the decoder to throw an error if it encounters whitespace characters. Otherwise it ignores them.
.RE
.TP
\fBuuencode\fR
@@ -118,8 +116,7 @@ During decoding, the following options are supported:
.TP
\fB\-strict\fR
.
-Instructs the decoder to throw an error if it encounters any characters that
-are not strictly part of the encoding itself. Otherwise it ignores them.
+Instructs the decoder to throw an error if it encounters whitespace characters. Otherwise it ignores them.
.RE
.VE 8.6
.SH "BINARY FORMAT"
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 18c12fa..5e86653 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBinary.c,v 1.51 2008/11/16 17:17:44 dkf Exp $
+ * RCS: @(#) $Id: tclBinary.c,v 1.52 2008/12/15 17:11:34 ferrieux Exp $
*/
#include "tclInt.h"
@@ -2288,7 +2288,7 @@ BinaryDecodeHex(
c = *data++;
if (!isxdigit((int) c)) {
- if (strict) {
+ if (strict || !isspace(c)) {
goto badChar;
}
i--;
@@ -2499,7 +2499,7 @@ BinaryDecodeUu(
if (data < dataend) {
d[i] = c = *data++;
if (c < 33 || c > 96) {
- if (strict) {
+ if (strict || !isspace(c)) {
goto badUu;
}
i--;
@@ -2509,6 +2509,7 @@ BinaryDecodeUu(
++cut;
}
}
+ if (cut>3) cut=3;
*cursor++ = (((d[0] - 0x20) & 0x3f) << 2)
| (((d[1] - 0x20) & 0x3f) >> 4);
*cursor++ = (((d[1] - 0x20) & 0x3f) << 4)
@@ -2606,7 +2607,7 @@ BinaryDecode64(
++cut;
}
} else {
- if (strict) {
+ if (strict || !isspace(c)) {
goto bad64;
}
i--;
diff --git a/tests/binary.test b/tests/binary.test
index 8b8a1ab..b23548e 100644
--- a/tests/binary.test
+++ b/tests/binary.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: binary.test,v 1.37 2008/09/10 13:50:04 dkf Exp $
+# RCS: @(#) $Id: binary.test,v 1.38 2008/12/15 17:11:34 ferrieux Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -2718,6 +2718,14 @@ test binary-75.23 {binary decode uuencode} -body {
set r [binary decode uuencode 86)C]
list [string length $r] $r
} -result {3 abc}
+test binary-75.24 {binary decode uuencode} -body {
+ set s "04)\# "
+ binary decode uuencode $s
+} -result ABC
+test binary-75.25 {binary decode uuencode} -body {
+ set s "04)\#z"
+ binary decode uuencode $s
+} -returnCodes error -match glob -result {invalid uuencode character "z" at position 4}
test binary-76.1 {byte array concat speed} -body {
set b1 [binary format H* [string repeat E9 1000000]]