--- a/libpurple/trie.c Wed Mar 26 01:02:47 2014 +0100
+++ b/libpurple/trie.c Wed Mar 26 01:48:39 2014 +0100
@@ -331,6 +331,7 @@
state = priv->root_state;
guchar character = src[i];
/* change state after processing a character */
@@ -345,10 +346,12 @@
if (state == priv->root_state)
+ /* Let's try a bit shorter suffix. */ state = state->longest_suffix;
/* if we reached a "found" state, let's process it */
@@ -356,12 +359,27 @@
state->found_word->data, user_data);
if (was_replaced || priv->reset_on_match) {
+ g_string_append_len(out, + state->found_word->word, + state->found_word->word_len); + /* skip a whole word, not a character */ i += state->found_word->word_len;
state = priv->root_state;
+ /* We skipped a character without finding any records, + * let's just copy it to the output. */ + g_string_append_c(out, character); return g_string_free(out, FALSE);