Last active
August 29, 2015 14:06
-
-
Save tombeynon/62700d424675d965a6fe to your computer and use it in GitHub Desktop.
Sanitizing Solr Requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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