NuGet/NuGetGallery — Issue #406: ParseException thrown if asterisk put as first character in lucene search
Author: dnolf
Created: 2012-02-09 02:47:01+00:00
State: open

I was playing around with the gallery and for some unknown reason, I put a asterisk in the search window as a wildcard and I got a exception on the screen.

I tracked it down to: Infrastructure\Lucene\LuceneSearchService.cs Line 83

It seems that Lucene can throw a ParserException.

Cannot parse '*Dave': '*' or '?' not allowed as first character in WildcardQuery

I am new to contributing to a open source project but would like to contribute. I am first seeking everyone's thoughts on how this should be handled.

A regex could be applied to the search query but I am not sure of all the possibilities that lucene.net would thrown an exxception, so the safest would be to put a try/catch could be put around it and then the search would report that no packages would be found.

Or should there be something that returns a error back to the page indicating that they used incorrect syntax in the search field.