diff options
author | Michael Zucci <zucchi@src.gnome.org> | 2000-11-24 15:06:45 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-11-24 15:06:45 +0800 |
commit | 05aaadc66b77c9f080b590fa19938de8ec80691d (patch) | |
tree | 29a0a25e2261139de414e4a6172e678fafa4322b /camel | |
parent | 189cb50426fc12b55a79c67a00064623ec964383 (diff) | |
download | gsoc2013-evolution-05aaadc66b77c9f080b590fa19938de8ec80691d.tar gsoc2013-evolution-05aaadc66b77c9f080b590fa19938de8ec80691d.tar.gz gsoc2013-evolution-05aaadc66b77c9f080b590fa19938de8ec80691d.tar.bz2 gsoc2013-evolution-05aaadc66b77c9f080b590fa19938de8ec80691d.tar.lz gsoc2013-evolution-05aaadc66b77c9f080b590fa19938de8ec80691d.tar.xz gsoc2013-evolution-05aaadc66b77c9f080b590fa19938de8ec80691d.tar.zst gsoc2013-evolution-05aaadc66b77c9f080b590fa19938de8ec80691d.zip |
little util to scan mailboxes for any and every address they contain.
* tests/data/getaddr.pl: little util to scan mailboxes for any and
every address they contain.
* tests/message/test2.c (main): Added a bunch of stuff to test
decoding/reencoding/etc of internationalised addresses.
* tests/message/lib/address-data.h: Copy of some unicode/other
testing data. **Beware** of editing this file in emacs, it'll
probably try and convert all the characters to something
unusable.
* tests/lib/camel-test.c (camel_test_break): Add a debugger hook
point.
* camel-mime-utils.c (quoted_encode): Check for space and convert
to _ separately.
(header_decode_mailbox): Fixed the 'check comments for realname'
code, problem was the domain getting code was skipping all
whitespace/comments before we could get a look-in. This is
approximate but fairly robust.
(header_decode_text): Dont use the c-type isspace func here, we
want a specific whitespace only.
(header_decode_text): If we have decoded words next to each other,
do not insert whitespaces between them, which is what rfc2047 requires.
(header_decode_text): Make c unsigned too.
svn path=/trunk/; revision=6658
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 26 | ||||
-rw-r--r-- | camel/camel-mime-utils.c | 70 | ||||
-rw-r--r-- | camel/tests/README | 4 | ||||
-rwxr-xr-x | camel/tests/data/getaddr.pl | 32 | ||||
-rw-r--r-- | camel/tests/lib/address-data.h | 93 | ||||
-rw-r--r-- | camel/tests/lib/camel-test.c | 6 | ||||
-rw-r--r-- | camel/tests/message/test2.c | 78 |
7 files changed, 243 insertions, 66 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index b4b3ca8015..8107aa8247 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,31 @@ 2000-11-24 Not Zed <NotZed@HelixCode.com> + * tests/data/getaddr.pl: little util to scan mailboxes for any and + every address they contain. + + * tests/message/test2.c (main): Added a bunch of stuff to test + decoding/reencoding/etc of internationalised addresses. + + * tests/message/lib/address-data.h: Copy of some unicode/other + testing data. **Beware** of editing this file in emacs, it'll + probably try and convert all the characters to something + unusable. + + * tests/lib/camel-test.c (camel_test_break): Add a debugger hook + point. + + * camel-mime-utils.c (quoted_encode): Check for space and convert + to _ separately. + (header_decode_mailbox): Fixed the 'check comments for realname' + code, problem was the domain getting code was skipping all + whitespace/comments before we could get a look-in. This is + approximate but fairly robust. + (header_decode_text): Dont use the c-type isspace func here, we + want a specific whitespace only. + (header_decode_text): If we have decoded words next to each other, + do not insert whitespaces between them, which is what rfc2047 requires. + (header_decode_text): Make c unsigned too. + * tests/README: Added at least some explanation of all this stuff. * tests/lib/camel-test.h (check_msg): Added a non-gcc version of diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 238b34156e..f1f08e25a0 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -809,9 +809,9 @@ quoted_encode(const unsigned char *in, int len, unsigned char *out, unsigned sho outptr = out; while (inptr < inend) { c = *inptr++; - if (camel_mime_special_table[c] & safemask) { - if (c==' ') - c = '_'; + if (c==' ') { + *outptr++ = '_'; + } else if (camel_mime_special_table[c] & safemask) { *outptr++ = c; } else { *outptr++ = '='; @@ -983,15 +983,17 @@ header_decode_text (const char *in, int inlen) GString *out; char *inptr, *inend, *start; char *decoded; - + unsigned char lastc = 0; + int wasdword = FALSE; + out = g_string_new (""); start = inptr = (char *) in; inend = inptr + inlen; while (inptr && inptr < inend) { - char c = *inptr++; + unsigned char c = *inptr++; - if (isspace (c)) { + if (is_lwsp(c)) { char *word, *dword; guint len; @@ -999,16 +1001,23 @@ header_decode_text (const char *in, int inlen) word = start; dword = rfc2047_decode_word (word, len); - + if (dword) { + if (!wasdword && lastc) + g_string_append_c(out, lastc); + g_string_append (out, dword); g_free (dword); + lastc = c; + wasdword = TRUE; } else { + if (lastc) + g_string_append_c(out, lastc); out = append_latin1 (out, word, len); + lastc = c; + wasdword = FALSE; } - - g_string_append_c (out, c); - + start = inptr; } } @@ -1023,9 +1032,13 @@ header_decode_text (const char *in, int inlen) dword = rfc2047_decode_word (word, len); if (dword) { + if (!wasdword && lastc) + g_string_append_c(out, lastc); g_string_append (out, dword); g_free (dword); } else { + if (lastc) + g_string_append_c(out, lastc); out = g_string_append_len (out, word, len); } } @@ -1797,6 +1810,7 @@ header_decode_mailbox(const char **in) GString *addr; GString *name = NULL; struct _header_address *address = NULL; + const char *comment = NULL; addr = g_string_new(""); @@ -1862,6 +1876,7 @@ header_decode_mailbox(const char **in) addr = g_string_append_c(addr, '.'); addr = g_string_append(addr, pre); } + comment = inptr; header_decode_lwsp(&inptr); } g_free(pre); @@ -1872,6 +1887,7 @@ header_decode_mailbox(const char **in) inptr++; addr = g_string_append_c(addr, '@'); + comment = inptr; dom = header_decode_domain(&inptr); addr = g_string_append(addr, dom); g_free(dom); @@ -1886,17 +1902,33 @@ header_decode_mailbox(const char **in) } else { w(g_warning("invalid route address, no closing '>': %s", *in)); } - } else if (name == NULL) { /* check for comment after address */ + } else if (name == NULL && comment != NULL && inptr>comment) { /* check for comment after address */ char *text, *tmp; - const char *comment = inptr; + const char *comstart, *comend; - header_decode_lwsp(&inptr); - if (inptr-comment > 3) { /* just guess ... */ - tmp = g_strndup(comment, inptr-comment); - text = header_decode_string(tmp); - name = g_string_new(text); - g_free(tmp); - g_free(text); + /* this is a bit messy, we go from the last known position, because + decode_domain/etc skip over any comments on the way */ + /* FIXME: This wont detect comments inside the domain itself, + but nobody seems to use that feature anyway ... */ + + d(printf("checking for comment from '%s'\n", comment)); + + comstart = strchr(comment, '('); + if (comstart) { + comstart++; + header_decode_lwsp(&inptr); + comend = inptr-1; + while (comend > comstart && comend[0] != ')') + comend--; + + if (comend > comstart) { + d(printf(" looking at subset '%.*s'\n", comend-comstart, comstart)); + tmp = g_strndup(comstart, comend-comstart); + text = header_decode_string(tmp); + name = g_string_new(text); + g_free(tmp); + g_free(text); + } } } diff --git a/camel/tests/README b/camel/tests/README index e9262541b4..2ffcc2dbcc 100644 --- a/camel/tests/README +++ b/camel/tests/README @@ -33,6 +33,8 @@ code has known limitations currently that stop it passing, but otherwise works for nominal input. To debug tests, set a breakpoint on camel_test_fail, which will be -called for any failure, even a non-fatal one. +called for any failure, even a non-fatal one. Or set it to +camel_test_break, which will only be called for fatal errors which are +to print to the screen. Michael <notzed@helixcode.com> diff --git a/camel/tests/data/getaddr.pl b/camel/tests/data/getaddr.pl new file mode 100755 index 0000000000..74a8a81f74 --- /dev/null +++ b/camel/tests/data/getaddr.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +# get addresses out of messages + +if ($#ARGV < 0) { + print "Usage: $0 message(s) mbox(es)\n"; + exit 1; +} + +foreach $name (@ARGV) { + open IN,"<$name"; + while (<IN>) { + if (/^From: (.*)/i + || /^To: (.*)/i + || /^Cc: (.*)/i) { + $base = $1; + while (<IN>) { + if (/^\s+(.*)/) { + $base .= " ".$1; + } else { + last; + } + } + $uniq{$base} = 1; + } + } + close IN; +} + +foreach $key (sort keys %uniq) { + print $key."\n"; +} diff --git a/camel/tests/lib/address-data.h b/camel/tests/lib/address-data.h new file mode 100644 index 0000000000..acecac596a --- /dev/null +++ b/camel/tests/lib/address-data.h @@ -0,0 +1,93 @@ +/* BE WARY of editing this file with emacs. + Otherwise it might be smart and try to re-encode everything, which + you really do not want +*/ + +static struct _a { + int count; + char *addr; + char *utf8; /* the utf8 in this table was generated by camel itself. As a result i'm making the assumption it + was right when it was created. It also depends on the format of ::format(),. which is likely to + change, to handle other bugs ! */ +} test_address[] = { + { 1, "\"=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?=\" <david@iiia.csic.es>", "David Gutiérrez Magallanes <david@iiia.csic.es>" }, + { 1, "\"=?iso-8859-1?Q?Jos=E9?= Antonio Milke G.\" <gerencia@ovoplus.com>", "José Antonio Milke G. <gerencia@ovoplus.com>" }, + { 1, "\"=?iso-8859-2?Q?Hi-Fi_Internert_market_=3D_1.Virtu=E1ln=ED_Internetov=E9_H?= =?iso-8859-2?Q?i-Fi_Studio?=\" <hifimarket@atlas.cz>", "Hi-Fi Internert market = 1.Virtuální Internetové Hi-Fi Studio <hifimarket@atlas.cz>" }, + { 3, "\"James M. Cape\" <jcape@jcinteractive.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx", "James M. Cape <jcape@jcinteractive.com>, Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx" }, + { 1, "=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?= <david@iiia.csic.es>", "David Gutiérrez Magallanes <david@iiia.csic.es>" }, + { 1, "=?ISO-8859-2?Q?Tomasz_K=B3oczko?= <kloczek@rudy.mif.pg.gda.pl>", "Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>" }, + { 1, "=?ISO-8859-2?Q?Vladim=EDr_Solnick=FD?= <vs@utia.cas.cz>", "Vladimír Solnický <vs@utia.cas.cz>" }, + { 1, "=?iso-8859-1?Q?=22S=F6rensen=2C_Daniel=22?= <dasar@wmdata.com>", "\"Sörensen, Daniel\" <dasar@wmdata.com>" }, + { 1, "=?iso-8859-1?Q?=C1=C2=AAQ=A7=CA?= <dennys@iim.nctu.edu.tw>", "ÁªQ§Ê <dennys@iim.nctu.edu.tw>" }, + { 1, "=?iso-8859-1?Q?=C1=C2=AAQ=A7=CA?= <dennys@news.iim.nctu.edu.tw>", "ÁªQ§Ê <dennys@news.iim.nctu.edu.tw>" }, + { 1, "=?iso-8859-1?Q?=C1kos?= Valentinyi <A.Valentinyi@soton.ac.uk>", "Ákos Valentinyi <A.Valentinyi@soton.ac.uk>" }, + { 1, "=?iso-8859-1?Q?Joaqu=EDn?= Cuenca Abela <cuenca@ie2.u-psud.fr>", "Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>" }, + { 2, "=?iso-8859-1?Q?Joaqu=EDn?= Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx", "Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx" }, + { 1, "=?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@celium.net>", "Joaquín Cuenca Abela <cuenca@celium.net>" }, + { 1, "=?iso-8859-1?Q?Juantom=E1s=20Garc=EDa?= <juantomas@lared.es>", "Juantomás García <juantomas@lared.es>" }, + { 1, "=?iso-8859-1?Q?Kenneth_ll=E9phaane_Christiansen?= <kenneth@ripen.dk>", "Kenneth lléphaane Christiansen <kenneth@ripen.dk>" }, + { 1, "=?iso-8859-1?Q?Kjell_Tage_=D8hman?= <tage@ohman.no>", "Kjell Tage Øhman <tage@ohman.no>" }, + { 1, "=?iso-8859-1?Q?Martin_Norb=E4ck?= <d95mback@dtek.chalmers.se>", "Martin Norbäck <d95mback@dtek.chalmers.se>" }, + { 1, "=?iso-8859-1?Q?P=E5llen?= <pollen@astrakan.hig.se>", "Pållen <pollen@astrakan.hig.se>" }, + { 1, "=?iso-8859-1?Q?Ville_P=E4tsi?= <drc@gnu.org>", "Ville Pätsi <drc@gnu.org>" }, + { 1, "=?iso-8859-1?q?Joaqu=EDn?= Cuenca Abela <cuenca@celium.net>", "Joaquín Cuenca Abela <cuenca@celium.net>" }, + { 1, "=?iso-8859-2?Q?Dra=BEen_Ka=E8ar?= <dave@srce.hr>", "Dražen Kačar <dave@srce.hr>" }, + /* yep this is right, this isn't valid so doesn't decode at all */ + { 1, "=?windows-1250?Q? \"Jaka Mo=E8nik\" ?= <jaka.mocnik@kiss.uni-lj.si>", "=?windows-1250?Q? Jaka Mo=E8nik ?= <jaka.mocnik@kiss.uni-lj.si>" }, + { 3, "George <jirka@5z.com>, Juantomas =?ISO-8859-1?Q?Garc=C3=83=C2=ADa?= <juantomas@lared.es>, gnome-hackers@gnome.org", "George <jirka@5z.com>, Juantomas GarcÃÂa <juantomas@lared.es>, gnome-hackers@gnome.org" }, + { 7, "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@celium.net>, sam th <sam@uchicago.edu>", "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, Joaquín Cuenca Abela <cuenca@celium.net>, sam th <sam@uchicago.edu>" }, + { 6, "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@ie2.u-psud.fr>", "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>" }, + { 1, "Kai =?iso-8859-1?Q?Gro=DFjohann?= <Kai.Grossjohann@CS.Uni-Dortmund.DE>", "Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>" }, + { 1, "Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=)", "Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>" }, + { 1, "Rickard =?iso-8859-1?Q?Nordstr=F6m?= <rzi@ebox.tninet.se>", "Rickard Nordström <rzi@ebox.tninet.se>" }, + { 1, "Tomasz =?iso-8859-2?q?K=B3oczko?= <kloczek@rudy.mif.pg.gda.pl>", "Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>" }, + { 1, "VALCKE =?iso-8859-1?Q?C=E9dric?= <cvalcke@freesurf.fr>", "VALCKE Cédric <cvalcke@freesurf.fr>" }, + { 1, "Ville =?iso-8859-1?q?P=E4tsi?= <drc@gnu.org>", "Ville Pätsi <drc@gnu.org>" }, + { 1, "david@iiia.csic.es (=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?=)", "David Gutiérrez Magallanes <david@iiia.csic.es>" }, + { 1, "kloczek@rudy.mif.pg.gda.pl (=?ISO-8859-2?Q?Tomasz_K=B3oczko?=)", "Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>" }, + { 1, "lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)", "Lasse Hillerøe Petersen <lassehp@imv.aau.dk>" }, + { 1, "ysato@etl.go.jp (Yutaka Sato =?ISO-2022-JP?B?GyRAOjRGI0stGyhK?=)", "Yutaka Sato 佐藤豊 <ysato@etl.go.jp>" }, +}; + +static struct _l { + char *type; + char *line; +} test_lines[] = { + /* commented out unsupported charsets - FIXME: camel should somehow handle this, although it can't really of course */ + /*{ "windows-1251", " .\n ?" },*/ + { "iso-8859-1", "Omple les miniatures de la finestra amb contingut de la pantalla" }, + { "ISO-8859-2", "Sprvce oken hbe s okrajem okna\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, + { "ISO-8859-1", "Vindueshndtering flytter dekorationsvindue istedet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, + { "ISO-8859-1", "Vorschaubilder der Fenster mit dem Bildschirminhalt ausfllen" }, + { "iso-8859-7", " (-)" }, + { "iso-8859-1", "You've chosen to disable the startup hint.\nTo re-enable it, choose \"Startup Hint\"\nin the GNOME Control Centre" }, + { "iso-8859-1", "El aplique de reloj muestra en su panel la fecha y la hora de forma simple \ny ligero " }, + { "iso-8859-1", "Applet ei vasta salvestusksule.\nKas peaks ta niisama sulgema, vi veel ootama?" }, + { "iso-8859-1", "Lehio kudeatzaileak lehioaren dekorazaioa mugiarazten\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, + { "iso-8859-15", "Nyt sovellukset, joiden ikkunoista on nkyvill vain otsikkopalkki" }, + { "ISO-8859-1", "Afficher les tches qui ne sont pas dans la liste des fentres" }, + { "iso-8859-1", "Nl applet ag tabhair freagra ar iarratas sbhil.\nBain amach an applet n lean ar fnacht?" }, + { "iso-8859-1", "Amosa-las tarefas agochadas da lista de fiestras (SKIP-WINLIST)" }, + { "iso-8859-2", "Az ablakkezel a dekorcit mozgassa az ablak helyett\n(AfterStep, Enlightenment, FVWM, IceWM, SawMill)" }, + { "iso-8859-1", "Riempi la finestra delle anteprime con il contenuto dello schermo" }, + { "euc-jp", "ɥޥ͡Ͼꥦɥư\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, + { "euc-kr", "â ڰ ٹ â ̵\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, + { "iso-8859-13", "Priedas neatsakinja praym isisaugoti.\nPaalinti pried ar laukti toliau?" }, + { "iso-8859-1", "Window manager verplaatst dekoratie\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, + { "iso-8859-1", "Vindushndtereren flytter dekorasjonsvinduet i stedet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, + { "iso-8859-2", "Przemieszczanie dekoracji zamiast okna\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, + { "iso-8859-1", "Este programa responsvel por executar outras aplicaes, embeber pequenos applets, a paz no mundo e crashes aleatrios do X." }, + { "iso-8859-1", "Mostrar tarefas que se escondem da lista de janelas (SKIP-WINLIST)" }, + { "koi8-r", " " }, + { "iso-8859-2", "Sprvca okien presva okraje okien\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, + { "iso-8859-2", "Kai posle, ki se skrivajo pred upravljalnik oken (SKIP-WINLIST)" }, + { "iso-8859-5", "Window a\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, + { "iso-8859-2", "Window menadzeri pomera dekoracioni prozor umesto toga\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, + { "iso-8859-1", "Fnsterhanteraren flyttar dekorationsfnstret istllet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, + /*{ "TSCII", "츼- ¡ 츼 (츼--Ţ)" },*/ + { "iso-8859-9", "Kaydetme isteine bir uygulak cevap vermiyor .\nUygula sileyim mi , yoksa bekleyeyim mi ?" }, + { "koi8-u", "ͦ æ ͦ צ\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, + { "iso-8859-1", "Cwand on scriftr est bodj fo, li scriftr t totes\nles apliketes dvins sont pierdowes. Bodj ci scriftr chal?" }, + { "gb2312", "ǨƵװδڹ(AfterStep, Enlightenment, FVWM, IceWM, SawMill)" }, + { "big5", "z̥uʸ˹\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, +}; diff --git a/camel/tests/lib/camel-test.c b/camel/tests/lib/camel-test.c index a913ad78a4..6a1e00addb 100644 --- a/camel/tests/lib/camel-test.c +++ b/camel/tests/lib/camel-test.c @@ -116,6 +116,11 @@ void camel_test_pull(void) g_free(node); } +/* where to set breakpoints */ +void camel_test_break(void) +{ +} + void camel_test_fail(const char *why, ...) { va_list ap; @@ -135,6 +140,7 @@ void camel_test_failv(const char *why, va_list ap) if ((nonfatal == NULL && camel_test_verbose > 0) || (nonfatal && camel_test_verbose > 1)) { printf("Failed.\n%s\n", text); + camel_test_break(); } g_free(text); diff --git a/camel/tests/message/test2.c b/camel/tests/message/test2.c index 8a3fe3c250..00bd6aabf2 100644 --- a/camel/tests/message/test2.c +++ b/camel/tests/message/test2.c @@ -11,51 +11,7 @@ #include <camel/camel-internet-address.h> #include <camel/camel-address.h> -/* a bunch of test strings in different encodings, just taken from gnome-core po files */ -/* see data/genline.pl */ -struct _l { - char *type; - char *line; -} test_lines[] = { - /* FIXME: for now, remove the types libunicode doesn't know about, this is tricky to fix */ - /* And at best, all we could do is translate it to X-Unknown, or something */ - /*{ "windows-1251", " .\n ?" },*/ - { "iso-8859-1", "Omple les miniatures de la finestra amb contingut de la pantalla" }, - { "ISO-8859-2", "Sprvce oken hbe s okrajem okna (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "ISO-8859-1", "Vindueshndtering flytter dekorationsvindue istedet (AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "ISO-8859-1", "Vorschaubilder der Fenster mit dem Bildschirminhalt ausfllen" }, - { "iso-8859-7", " (-)" }, - { "iso-8859-1", "You've chosen to disable the startup hint. To re-enable it, choose \"Startup Hint\" in the GNOME Control Centre" }, - { "iso-8859-1", "El aplique de reloj muestra en su panel la fecha y la hora de forma simple y ligero " }, - { "iso-8859-1", "Applet ei vasta salvestusksule. Kas peaks ta niisama sulgema, vi veel ootama?" }, - { "iso-8859-1", "Lehio kudeatzaileak lehioaren dekorazaioa mugiarazten (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-15", "Nyt sovellukset, joiden ikkunoista on nkyvill vain otsikkopalkki" }, - { "ISO-8859-1", "Afficher les tches qui ne sont pas dans la liste des fentres" }, - { "iso-8859-1", "Nl applet ag tabhair freagra ar iarratas sbhil. Bain amach an applet n lean ar fnacht?" }, - { "iso-8859-1", "Amosa-las tarefas agochadas da lista de fiestras (SKIP-WINLIST)" }, - { "iso-8859-2", "Az ablakkezel a dekorcit mozgassa az ablak helyett (AfterStep, Enlightenment, FVWM, IceWM, SawMill)" }, - { "iso-8859-1", "Riempi la finestra delle anteprime con il contenuto dello schermo" }, - { "euc-jp", "ɥޥ͡Ͼꥦɥư (AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "euc-kr", "â ڰ ٹ â ̵ (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-13", "Priedas neatsakinja praym isisaugoti. Paalinti pried ar laukti toliau?" }, - { "iso-8859-1", "Window manager verplaatst dekoratie (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-1", "Vindushndtereren flytter dekorasjonsvinduet i stedet (AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "iso-8859-2", "Przemieszczanie dekoracji zamiast okna (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-1", "Este programa responsvel por executar outras aplicaes, embeber pequenos applets, a paz no mundo e crashes aleatrios do X." }, - { "iso-8859-1", "Mostrar tarefas que se escondem da lista de janelas (SKIP-WINLIST)" }, - { "koi8-r", " " }, - { "iso-8859-2", "Sprvca okien presva okraje okien (AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "iso-8859-2", "Kai posle, ki se skrivajo pred upravljalnik oken (SKIP-WINLIST)" }, - { "iso-8859-5", "Window a (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-2", "Window menadzeri pomera dekoracioni prozor umesto toga (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-1", "Fnsterhanteraren flyttar dekorationsfnstret istllet (AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - /*{ "TSCII", "츼- ¡ 츼 (츼--Ţ)" },*/ - { "iso-8859-9", "Kaydetme isteine bir uygulak cevap vermiyor . Uygula sileyim mi , yoksa bekleyeyim mi ?" }, - { "koi8-u", "ͦ æ ͦ צ (AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "iso-8859-1", "Cwand on scriftr est bodj fo, li scriftr t totes les apliketes dvins sont pierdowes. Bodj ci scriftr chal?" }, - { "gb2312", "ǨƵװδڹ(AfterStep, Enlightenment, FVWM, IceWM, SawMill)" }, - { "big5", "z̥uʸ˹ (AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, -}; +#include "address-data.h" static char *convert(const char *in, const char *from, const char *to) { @@ -330,8 +286,38 @@ int main(int argc, char **argv) camel_test_end(); - /* FIXME: Add test of decoding of externally defined addresses */ + camel_test_start("CamelInternetAddress, I18N decode"); + + for (i=0;i<ARRAY_LEN(test_address);i++) { + push("Testing address line %d '%s'", i, test_address[i].addr); + + addr = camel_internet_address_new(); + push("checking decoded"); + check(camel_address_decode(CAMEL_ADDRESS(addr), test_address[i].addr) == test_address[i].count); + format = camel_address_format(CAMEL_ADDRESS(addr)); + check(strcmp(format, test_address[i].utf8) == 0); + test_free(format); + pull(); + + push("Comparing re-encoded output"); + addr2 = CAMEL_INTERNET_ADDRESS(camel_internet_address_new()); + enc = camel_address_encode(CAMEL_ADDRESS(addr)); + check_msg(camel_address_decode(CAMEL_ADDRESS(addr2), enc) == test_address[i].count, "enc = '%s'", enc); + test_free(enc); + test_address_compare(addr, addr2); + check_unref(addr2, 1); + pull(); + + check_unref(addr, 1); + + pull(); + } + + camel_test_end(); + /* FIXME: Add test of decoding of broken addresses */ return 0; } + + |