Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-03-21 19:04:12 +0300
committerJarka Kadlecova <jarka@gitlab.com>2017-03-21 19:04:12 +0300
commit3750766f425f09439257cbe4934877a17bf815ea (patch)
tree349ff8424facd52ec4e27c081848f99f31608ca6 /app/models/route.rb
parent46146e33f2f8dcbd52ee50eb9142887344b8c367 (diff)
Escape route path for LIKE queries
Diffstat (limited to 'app/models/route.rb')
-rw-r--r--app/models/route.rb4
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 = {}