diff options
Diffstat (limited to 'unicode')
| -rw-r--r-- | unicode/ChangeLog | 5 | ||||
| -rw-r--r-- | unicode/Makefile.am | 3 | ||||
| -rw-r--r-- | unicode/unicode.c | 6 | ||||
| -rw-r--r-- | unicode/unicodetest.c | 22 |
4 files changed, 35 insertions, 1 deletions
diff --git a/unicode/ChangeLog b/unicode/ChangeLog index f29176e..a9203d3 100644 --- a/unicode/ChangeLog +++ b/unicode/ChangeLog @@ -1,3 +1,8 @@ +2018-07-13 Sam Varshavchik <mrsam@courier-mta.com> + + * unicode.c: Fix error and validation of valid modified-utf7 + encoding. + 2018-07-11 Sam Varshavchik <mrsam@courier-mta.com> * unicode.c: Implement unicode_x_smap_modutf8 pseudo-encoding. diff --git a/unicode/Makefile.am b/unicode/Makefile.am index 0f6784e..764614b 100644 --- a/unicode/Makefile.am +++ b/unicode/Makefile.am @@ -182,6 +182,9 @@ check-am: unicodetest test "`./unicodetest --smap 'foo&bar'`" = 'foo&-bar' test "`./unicodetest --smap 'foo.bar'`" = 'foo&AC4-bar' test "`./unicodetest --totitle 'tÄst'`" = 'Täst' + test "`./unicodetest --modutf7toutf8 'foo&bar'`" = '[error]' + test "`./unicodetest --modutf7toutf8 'foo&-bar'`" = 'foo&bar' + test "`./unicodetest --modutf7toutf8 'foo:bar'`" = 'foo\072bar' test "`./graphemetest 0x0d 0x0a`" = "0" # GB3 test "`./graphemetest 0x0d 0x41`" = "1" # GB4 test "`./graphemetest 0x41 0x0d`" = "1" # GB5 diff --git a/unicode/unicode.c b/unicode/unicode.c index 82d5c21..e320f9f 100644 --- a/unicode/unicode.c +++ b/unicode/unicode.c @@ -623,11 +623,15 @@ struct unicode_convert_fromimaputf7 { /* Flush the accumulated UCS-2 stream */ #define convert_fromutf7_flush(p) do { \ - (p)->errflag=(*(p)->hdr.next->convert_handler) \ + int rc=(*(p)->hdr.next->convert_handler) \ ((p)->hdr.next->ptr, \ (const char *)(p)->convbuf, \ (p)->convbuf_cnt * \ sizeof((p)->convbuf[0])); \ + \ + if (rc) \ + (p)->errflag=rc; \ + \ (p)->convbuf_cnt=0; \ } while (0) diff --git a/unicode/unicodetest.c b/unicode/unicodetest.c index b309ad6..e9e4228 100644 --- a/unicode/unicodetest.c +++ b/unicode/unicodetest.c @@ -140,6 +140,28 @@ int main(int argc, char **argv) ++argn; } + if (argn < argc && strcmp(argv[argn], "--modutf7toutf8") == 0) + { + while (++argn < argc) + { + int error=0; + char *p=unicode_convert_tobuf(argv[argn], + unicode_x_imap_modutf7, + unicode_x_smap_modutf8, + &error); + + if (p) + { + printf("%s\n", p); + free(p); + } + else + { + printf("[error]\n"); + } + } + } + if (argn < argc && strcmp(argv[argn], "--totitle") == 0) { ++argn; |
