The default highlighter output is bogus if you're trying to use the
snippets in a web browser.  With the default <em></em> delimiters, the
temptation is to just stick the snippets in an innerHTML property, but
the problem is that other HTML special characters (< > and &) are not
escaped.  For example, a highlight snippet might look like this:

"<em>this</em> & that"

... which when assigned to an innerHTML will throw an exception (in
Firefox at least).  The other option is to just assign the snippets to
an HTML text node, in which case your user sees a literal
"<em>this</em>" on the screen, which isn't desirable either.

There is no simple solution to this problem because the simple
formatter lacks an escape function.  Even if I set the pre/post to
[[[!!!111ONE]]], it would still fail when searching for this message.
The more satisfactory solution would seem to be to escape special
chars in the simple formatter, at least optionally.
hl.simple.escapeHTML=true?  Another option would be to use a structure
for highlight output instead of bare string.

Note that a resolution to SOLR-175 would also solve this.

Anybody have a way to work around this?

-jwb

Reply via email to