Skip to content

Commit

Permalink
change escaping (bnc#630988)
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaltom committed Dec 6, 2010
1 parent cd8c463 commit 08a316f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/search_controller.rb
Expand Up @@ -34,15 +34,15 @@ def perform_search

base = @baseproject=="ALL" ? "" : @baseproject
begin
@result = Seeker.prepare_result(CGI.escape(@query).gsub("+", " "), base, @project, @exclude_filter, @exclude_debug)
@result = Seeker.prepare_result(@query, base, @project, @exclude_filter, @exclude_debug)
if @current_page == 1 # ignore sub pages
SearchHistory.create :query => @query, :base => @baseproject, :patterns => @result.pattern_count,
:binaries => @result.binary_count, :count => @result.length
end
rescue => e
search_error, code, api_exception = ActiveXML::Transport.extract_error_message e
if code == "413"
@result = Seeker.prepare_result(CGI.escape("\"#{@query}\"").gsub("+", " "), base, @project, @exclude_filter, @exclude_debug)
@result = Seeker.prepare_result(@query, base, @project, @exclude_filter, @exclude_debug)
unless @result.blank?
flash.now[:note] = _("Switched to exact match due to too many hits on substring search.")
else
Expand Down
3 changes: 2 additions & 1 deletion app/models/seeker.rb
Expand Up @@ -25,6 +25,7 @@ def self.prepare_result(query, baseproject=nil, project=nil, exclude_filter=nil,
class SearchResult < Array
def self.search(query, baseproject, project=nil, exclude_filter=nil, exclude_debug=false)

query = query.gsub(/['"()]/, "")
words = query.split(" ").select {|part| !part.match(/^[0-9_\.-]+$/) }
versions = query.split(" ").select {|part| part.match(/^[0-9_\.-]+$/) }
logger.debug "splitted words and version: #{words.inspect} #{versions.inspect}"
Expand All @@ -39,7 +40,7 @@ def self.search(query, baseproject, project=nil, exclude_filter=nil, exclude_deb
xpath += " and @project = '#{project}' " unless project.blank?
xpath += " and not(contains-ic(@name, '-debuginfo')) and not(contains-ic(@name, '-debugsource'))" if exclude_debug
xpath += " and not(contains-ic(@project, '#{exclude_filter}'))" unless exclude_filter.blank?

bin = Seeker.find :binary, :match => xpath
pat = Seeker.find :pattern, :match => xpath
result = new(query)
Expand Down

0 comments on commit 08a316f

Please sign in to comment.