I've changed the code to use camel_utf8_getc_limit() so that we can prevent your concerns about the handling of broken utf8 as well as making sure not to go beyond the end of the buffer (which I think inptr = g_utf8_find_next_char (inptr, inend); would have solved, but just in case). Jeff On Tue, 2004-08-03 at 23:22 -0400, Jeffrey Stedfast wrote: > On Tue, 2004-08-03 at 22:48, Not Zed wrote: > > will that handle broken utf8 properly? g_utf8_next_char could go off > > the end of the string, or go nowhere, could it infinite loop too? > > that's why the while conditional also checks inptr < inend - shouldn't > that be enough? tho maybe I should use g_utf8_find_next_char() so that I > can pass in the inend pointer... > > can't infinite loop afaict. > > Jeff > > > > > On Tue, 2004-08-03 at 13:20 -0400, Jeffrey Stedfast wrote: > > > http://bugzilla.ximian.com/show_bug.cgi?id=62136 > > > > > > The lone '@' character in his signature was causing the problem since > > > the trie_search() would return that position but the ::start() method > > > would fail (it's not an email address) and so the function would > > > immediately return FALSE (aka "no patterns found"). > > > > > > changed the code to loop until it has scanned the entire buffer it was > > > given. > > > > > > Jeff > > > text/plain attachment (62136.patch) > > > ? 24026.patch > > > ? 62136.patch > > > ? body > > > ? body.c > > > ? body.txt > > > ? body2.txt > > > ? charset-map.c > > > ? charset-map.diff > > > ? class.sh > > > ? cmsutil.c > > > ? date.patch > > > ? flags > > > ? foo > > > ? foo.txt > > > ? foo2.txt > > > ? gw-body.txt > > > ? iso > > > ? iso.c > > > ? lang.patch > > > ? namespace.sh > > > ? smime > > > ? providers/imap4/reconnect.patch > > > ? tests/data/camel-mime-tests.tar.gz > > > Index: ChangeLog > > > =================================================================== > > > RCS file: /cvs/gnome/evolution/camel/ChangeLog,v > > > retrieving revision 1.2234 > > > diff -u -r1.2234 ChangeLog > > > --- ChangeLog 3 Aug 2004 16:31:47 -0000 1.2234 > > > +++ ChangeLog 3 Aug 2004 17:14:26 -0000 > > > @@ -1,5 +1,11 @@ > > > 2004-08-03 Jeffrey Stedfast <fejj novell com> > > > > > > + * camel-url-scanner.c (camel_url_scanner_scan): In the case of > > > + start() or end() failing, loop starting with the first character > > > + immediately following the failed match position. Fixes bug #62136. > > > + > > > +2004-08-03 Jeffrey Stedfast <fejj novell com> > > > + > > > * providers/imap4/camel-imap4-store.c (imap4_construct): Pass a > > > reconnect func. > > > > > > Index: camel-url-scanner.c > > > =================================================================== > > > RCS file: /cvs/gnome/evolution/camel/camel-url-scanner.c,v > > > retrieving revision 1.13 > > > diff -u -r1.13 camel-url-scanner.c > > > --- camel-url-scanner.c 28 Jun 2004 00:18:20 -0000 1.13 > > > +++ camel-url-scanner.c 3 Aug 2004 17:14:26 -0000 > > > @@ -76,29 +76,33 @@ > > > gboolean > > > camel_url_scanner_scan (CamelUrlScanner *scanner, const char *in, size_t inlen, urlmatch_t *match) > > > { > > > - const char *pos, *inend; > > > + const char *pos, *inptr, *inend; > > > urlpattern_t *pat; > > > int pattern; > > > > > > g_return_val_if_fail (scanner != NULL, FALSE); > > > g_return_val_if_fail (in != NULL, FALSE); > > > > > > - if (!(pos = e_trie_search (scanner->trie, in, inlen, &pattern))) > > > - return FALSE; > > > - > > > - pat = g_ptr_array_index (scanner->patterns, pattern); > > > - > > > - match->pattern = pat->pattern; > > > - match->prefix = pat->prefix; > > > - > > > + inptr = in; > > > inend = in + inlen; > > > - if (!pat->start (in, pos, inend, match)) > > > - return FALSE; > > > > > > - if (!pat->end (in, pos, inend, match)) > > > - return FALSE; > > > + do { > > > + if (!(pos = e_trie_search (scanner->trie, inptr, inlen, &pattern))) > > > + return FALSE; > > > + > > > + pat = g_ptr_array_index (scanner->patterns, pattern); > > > + > > > + match->pattern = pat->pattern; > > > + match->prefix = pat->prefix; > > > + > > > + if (pat->start (in, pos, inend, match) && pat->end (in, pos, inend, match)) > > > + return TRUE; > > > + > > > + inptr = g_utf8_next_char (pos); > > > + inlen = inend - inptr; > > > + } while (inptr != NULL && inptr < inend); > > > > > > - return TRUE; > > > + return FALSE; > > > } > > > > > > > > -- > > > > Michael Zucchi <notzed ximian com> > > "born to die, live to work, it's > > all downhill from here" > > Novell's Evolution and Free > > Software Developer > > _______________________________________________ > evolution-patches mailing list > evolution-patches lists ximian com > http://lists.ximian.com/mailman/listinfo/evolution-patches > -- Jeffrey Stedfast Evolution Hacker - Novell, Inc. fejj ximian com - www.novell.com
Index: ChangeLog =================================================================== RCS file: /cvs/gnome/evolution/camel/ChangeLog,v retrieving revision 1.2234 diff -u -r1.2234 ChangeLog --- ChangeLog 3 Aug 2004 16:31:47 -0000 1.2234 +++ ChangeLog 4 Aug 2004 18:41:33 -0000 @@ -1,5 +1,11 @@ 2004-08-03 Jeffrey Stedfast <fejj novell com> + * camel-url-scanner.c (camel_url_scanner_scan): In the case of + start() or end() failing, loop starting with the first character + immediately following the failed match position. Fixes bug #62136. + +2004-08-03 Jeffrey Stedfast <fejj novell com> + * providers/imap4/camel-imap4-store.c (imap4_construct): Pass a reconnect func. Index: camel-url-scanner.c =================================================================== RCS file: /cvs/gnome/evolution/camel/camel-url-scanner.c,v retrieving revision 1.13 diff -u -r1.13 camel-url-scanner.c --- camel-url-scanner.c 28 Jun 2004 00:18:20 -0000 1.13 +++ camel-url-scanner.c 4 Aug 2004 18:41:33 -0000 @@ -30,6 +30,7 @@ #include <ctype.h> #include "e-util/e-trie.h" +#include "camel-utf8.h" #include "camel-url-scanner.h" @@ -76,29 +77,36 @@ gboolean camel_url_scanner_scan (CamelUrlScanner *scanner, const char *in, size_t inlen, urlmatch_t *match) { - const char *pos, *inend; + const char *pos, *inptr, *inend; urlpattern_t *pat; int pattern; g_return_val_if_fail (scanner != NULL, FALSE); g_return_val_if_fail (in != NULL, FALSE); - if (!(pos = e_trie_search (scanner->trie, in, inlen, &pattern))) - return FALSE; - - pat = g_ptr_array_index (scanner->patterns, pattern); - - match->pattern = pat->pattern; - match->prefix = pat->prefix; - + inptr = in; inend = in + inlen; - if (!pat->start (in, pos, inend, match)) - return FALSE; - if (!pat->end (in, pos, inend, match)) - return FALSE; + do { + if (!(pos = e_trie_search (scanner->trie, inptr, inlen, &pattern))) + return FALSE; + + pat = g_ptr_array_index (scanner->patterns, pattern); + + match->pattern = pat->pattern; + match->prefix = pat->prefix; + + if (pat->start (in, pos, inend, match) && pat->end (in, pos, inend, match)) + return TRUE; + + inptr = pos; + if (camel_utf8_getc_limit ((const unsigned char **) &inptr, inend) == 0xffff) + break; + + inlen = inend - inptr; + } while (inptr < inend); - return TRUE; + return FALSE; }
Attachment:
smime.p7s
Description: S/MIME cryptographic signature