diff options
Diffstat (limited to 'camel/camel-url-scanner.c')
-rw-r--r-- | camel/camel-url-scanner.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/camel/camel-url-scanner.c b/camel/camel-url-scanner.c index 891a47610e..1240731f9b 100644 --- a/camel/camel-url-scanner.c +++ b/camel/camel-url-scanner.c @@ -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 @@ camel_url_scanner_add (CamelUrlScanner *scanner, urlpattern_t *pattern) 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; } |