Skip to content

Instantly share code, notes, and snippets.

@tombeynon
Last active August 29, 2015 14:06
Show Gist options
  • Save tombeynon/62700d424675d965a6fe to your computer and use it in GitHub Desktop.
Save tombeynon/62700d424675d965a6fe to your computer and use it in GitHub Desktop.
Sanitizing Solr Requests
# http://pivotallabs.com/sanitizing-solr-requests/
module SolrStringSanitizer
ILLEGAL_SOLR_CHARACTERS_REGEXP = /[\+\-\!\(\)\{\}\[\]\^\|"~\*\?:;&]/
def self.sanitize(string)
if string
string.gsub(ILLEGAL_SOLR_CHARACTERS_REGEXP,"")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment