Escape user input before building regexps
This commit is contained in:
1 parent
25adc82695
commit
b6969c6dd0
2 files changed
+2
-2
No files matched your search
@@ -298,7 +298,7 @@ end
|
||||
keywords = params["q"]
|
||||
keywords = keywords.strip.nil? ? keywords : keywords.strip
|
||||
regexes = keywords.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
|
||||
regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+word+".*", "i")})
|
||||
regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+Regexp.escape(word)+".*", "i")})
|
||||
|
||||
column = table.table_columns.where(:type.in => ["text","editor"])
|
||||
columns = []
|
||||
|
||||
@@ -146,7 +146,7 @@ class UniversalTablesController < ApplicationController
|
||||
# regexes = v.split(/\s+(?=(?:[^"]*"[^"]*")*[^"]*$)/)
|
||||
# regex = Regexp.union(regexes.map{|word| Regexp.new(".*"+word+".*", "i")})
|
||||
# end
|
||||
regex = Regexp.new(".*"+v+".*", "i")
|
||||
regex = Regexp.new(".*"+Regexp.escape(v.to_s)+".*", "i")
|
||||
case column.type
|
||||
when "text"
|
||||
columns = column.column_entries.any_of([{"text.en" => regex}, {"text.zh_tw" => regex}])
|
||||
|
||||
Reference in new issue
Block a user