[tracker/parser-unicode-libs-review] Perform the max word length check



commit 59485ed0f711b7e0ab6f7071059710a7e5fd5c62
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Fri May 7 12:39:40 2010 +0200

    Perform the max word length check

 src/libtracker-fts/tracker-parser-libicu.c       |    7 +++++++
 src/libtracker-fts/tracker-parser-libunistring.c |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-fts/tracker-parser-libicu.c b/src/libtracker-fts/tracker-parser-libicu.c
index 0a280f5..33c062c 100644
--- a/src/libtracker-fts/tracker-parser-libicu.c
+++ b/src/libtracker-fts/tracker-parser-libicu.c
@@ -205,6 +205,13 @@ parser_next (TrackerParser *parser,
 		/* g_debug ("next_word_offset_utf8: %" G_GSIZE_FORMAT, next_word_offset_utf8); */
 		/* g_debug ("current_word_offset_utf8: %" G_GSIZE_FORMAT, current_word_offset_utf8); */
 
+		/* Skip the word if longer than the maximum allowed */
+		if (word_length_utf8 >= parser->max_word_length) {
+			/* Skip this word and keep on looping */
+			parser->cursor = next_word_offset_uchar;
+			continue;
+		}
+
 		/* Get word info... */
 		if (!get_word_info (&parser->utxt[parser->cursor],
 		                    word_length_uchar,
diff --git a/src/libtracker-fts/tracker-parser-libunistring.c b/src/libtracker-fts/tracker-parser-libunistring.c
index 7f6fc6b..bad3cea 100644
--- a/src/libtracker-fts/tracker-parser-libunistring.c
+++ b/src/libtracker-fts/tracker-parser-libunistring.c
@@ -189,6 +189,13 @@ parser_next (TrackerParser *parser,
 			continue;
 		}
 
+		/* Skip the word if longer than the maximum allowed */
+		if (word_length >= parser->max_word_length) {
+			/* Skip this word and keep on looping */
+			parser->cursor += word_length;
+			continue;
+		}
+
 		/* check if word is reserved and skip it if so */
 		if (parser->parse_reserved_words &&
 		    tracker_parser_is_reserved_word_utf8 (&parser->txt[parser->cursor],



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