diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-03-21 17:04:12 +0100 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-03-21 17:04:12 +0100 |
commit | 3750766f425f09439257cbe4934877a17bf815ea (patch) | |
tree | 349ff8424facd52ec4e27c081848f99f31608ca6 /app/models/route.rb | |
parent | 46146e33f2f8dcbd52ee50eb9142887344b8c367 (diff) | |
download | gitlab-ce-3750766f425f09439257cbe4934877a17bf815ea.tar.gz |
Escape route path for LIKE queries
Diffstat (limited to 'app/models/route.rb')
-rw-r--r-- | app/models/route.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/route.rb b/app/models/route.rb index 41e6eb7cb73..4b3efab5c3c 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -10,9 +10,11 @@ class Route < ActiveRecord::Base after_update :rename_descendants + scope :inside_path, -> (path) { where('routes.path LIKE ?', "#{sanitize_sql_like(path)}/%") } + def rename_descendants if path_changed? || name_changed? - descendants = Route.where('path LIKE ?', "#{path_was}/%") + descendants = self.class.inside_path(path_was) descendants.each do |route| attributes = {} |