Re: [evolution-patches] patch for bug #62136 (url highlighting)




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?

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]