diff --git a/data/msfweb/app/controllers/application.rb b/data/msfweb/app/controllers/application.rb index c40c8fcf74..505b069e9f 100644 --- a/data/msfweb/app/controllers/application.rb +++ b/data/msfweb/app/controllers/application.rb @@ -3,27 +3,39 @@ class ApplicationController < ActionController::Base def search_modules(mlist, terms) - res = [] + res = {} unless terms return nil end + # Match search terms mlist.each do |m| + if (terms.length == 0) + res[m.name]=m + next + end + if (m.name.downcase.index(terms.downcase)) - res << m + res[m.name]=m next end if (m.description.downcase.index(terms.downcase)) - res << m + res[m.name]=m next end end - res + # Sort the modules by name + list = [] + res.keys.sort.each do |n| + list << res[n] + end + + list end end