Zach Brock's blog



Zach BrockZach Brock
Sanitizing Solr requests
edit Posted by Zach Brock on Friday July 17, 2009 at 01:29PM

If you're accepting user input for Solr (which I expect most projects using it are), you've probably noticed that you need to sanitize what queries you pass to Solr. After reading a bunch of conflicting documentation and blog posts, I put together a simple little module to handle it for you. It should strip out everything that would cause Solr to throw an error on a query string. Let me know if it works for you or if I missed any corner cases!

module SolrStringSanitizer
  ILLEGAL_SOLR_CHARACTERS_REGEXP = /\+|\-|!|(|)|{|}|[|]|\^|\|"|~|*|\?|:|;|&&|\|\|/

  def self.sanitize(string)
    if string
      string.gsub(ILLEGAL_SOLR_CHARACTERS_REGEXP,"")
    end
  end
end

Zach BrockZach Brock
How to make Firebug 1.4 behave sanely
edit Posted by Zach Brock on Monday July 06, 2009 at 11:33PM

As has been noted a few times, the new activation model in Firebug 1.4 is kind of psychotic. The main problem seems to be that the Firebug developers have disconnected the formerly linked concepts of "open" and "activated" for a few reasons that make sense to the developers, but make no sense to the users. Unless you've really internalized how Firebug works under the hood (and there are probably a few dozen people like that in the world), Firebug now seems to randomly choose whether it's going to be open or closed when you visit a page. Not fun.

The workaround that we've found is to force firebug to be active on all pages. You can do this by right clicking the Firebug icon in the bottom right and checking "On for all web pages". This makes Firebug behave mostly like the old way where the panel would stay open as you browsed around until you closed it. The big caveat is that it only stays closed if you use the firebug icon in the bottom right of your window, not the close panel button.

On for all web pages

This will slow your browser down a lot on ajax heavy sites like Pivotal Tracker or Gmail. You can get around that to a certain extent by disabling the Net tab on those domains, which will keep it from displaying every XHR request.

disable net panel

Hopefully this helps, and hopefully the Firebug 1.4 final release has a saner activation model...