alastair/python-musicbrainz-ngs — Issue #36: Avoid Bad Request when searching for "AND" or "OR"
Author: sampsyo
Created: 2012-01-31 23:44:48+00:00
State: open

The `search_*` functions' keyword arguments are escaped for inclusion in Lucene queries, but strings that look like boolean operators (e.g., "AND" and "OR" in upper case) still work as boolean operators. This can cause undesired behavior when someone intends to actually search for one of these words, or, more seriously, it leads to an HTTP 400 error ("Bad Request") when the query seems malformed. For example, if OR appears at the end of a query part (as in ``album:(PORTLAND, OR)``), an error occurs.

I can think of three ways of addressing this:
* Lower case all keyword arguments so they can't contain binary operators. (The `query` parameter can still be used if the user actually wants to use boolean operators.)
* Detect incorrect usage of boolean operators and throw an error on the client side.
* Leave it as is, but document the behavior.

I think the first seems the most reasonable. I'll implement it unless anyone has an objection.