Made sure all of the incoming database query stuff was properly quoted for bug #8365.