When putting together fts, we never quite could come up with a really
solid way to handle snippets.  A big factor was that fts is embedded
w/in SQLite, not directly w/in your program, so it's sometimes
challenging to provide a really wide API.

This is why there is both a snippet() function and an offsets()
function.  snippet() is mostly meant for simple use-cases, while
offsets() is there for when you need to gin up your own awesome
snippet algorithm.

WRT stripping tags, you might consider putting together your own
tokenizer that strips them out, depending on whether you want tags to
be searchable or not.  Tags like <b> or <i> are probably not a
terrible problem, but others like <script> or <table> which represent
real words might materially impact your query results.

-scott


On Sat, Sep 6, 2008 at 4:46 PM, Peter Hoffmann <[EMAIL PROTECTED]> wrote:
> Is there a common practice on quoting/sanitizing the snippets
> generated by the fts search?
>
> If I have "foo <b> bar lee" in one field and search for bar, the
> snippet function will return  "foo <b> <b>bar</b> lee", which is
> obvious not what I want and can easily be used for cross-site
> scripting.
>
> I can think about two strategies to avoid this:
>
> 1) The first one is to strip out all tags before inserting new text
> into the virtual table. I don't want to do this, because I have a pure
> text interface too, where the tags in results won't hurt.
>
> 2) Specify two random strings to the snippet function for quoting, eg,
> snippet(poem, '23453242', '435345345', '...') and use them to split
> the snippet afterwards and do the sanitizing then.
>
>
> Any other solutions? Maybe the sanitize function has a hidden feature for 
> this?
>
> Regards Peter
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to