mirror of
git://jb55.com/damus
synced 2024-10-06 11:43:21 +00:00
nostrdb/search: fix infinite loop when parsing some notes
Our word parser gets stuck on some notes with utf8 chars. Make sure we are always advancing so we don't get stuck. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
0e0c53145f
commit
b74bde5cc4
@ -2218,6 +2218,7 @@ static inline int consume_until_boundary(struct cursor *cur) {
|
|||||||
// TODO: We should work towards
|
// TODO: We should work towards
|
||||||
// handling all UTF-8 characters.
|
// handling all UTF-8 characters.
|
||||||
//printf("Invalid UTF-8 code point: %x\n", c);
|
//printf("Invalid UTF-8 code point: %x\n", c);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2305,6 +2306,14 @@ static int ndb_parse_words(struct cursor *cur, void *ctx, ndb_word_parser_fn fn)
|
|||||||
if (word_len == 0 && cur->p >= cur->end)
|
if (word_len == 0 && cur->p >= cur->end)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (word_len == 0) {
|
||||||
|
if (!cursor_skip(cur, 1))
|
||||||
|
break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ndb_debug("writing word index '%.*s'\n", word_len, word);
|
||||||
|
|
||||||
if (!fn(ctx, word, word_len, words))
|
if (!fn(ctx, word, word_len, words))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user