Solarium (a PHP client for Solr) has a helper method to escape search terms
that uses a regex to escape special characters.

https://github.com/solariumphp/solarium/blob/c2744ff706a2f0be148a45d702700fc346429679/src/Core/Query/Helper.php#L82

Thomas

Op wo 29 mei 2024 om 16:11 schreef Dmitri Maziuk <dmitri.maz...@gmail.com>:

> Hi all,
>
> our website has a search box that essentially passes its contents to
> Solr without any massaging. This works fine 99% of the time, the other
> 1% is when a misbehaving bot hits it and tries stuffing all sorts of
> crap in there.
>
> Then bad things happen: Java's overly verbose exception stack traces
> fill up the disk faster than the logs are rotated, CPU load spikes, etc.
>
> So, question: does anyone know of a validator/sanitizer we can use clean
> up the terms before passing them on to Solr? -- My google-fu fails to
> find one.
>
> TIA
> Dima
>

Reply via email to