From bfd21461dfd5881c6e9cad087bca7de1e30de94b Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 7 Jan 2016 12:06:45 +0530 Subject: [PATCH] FIX: proper regex for category slug validation --- app/models/category.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/category.rb b/app/models/category.rb index 80b2a1a5c7d..0ee810e6410 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -230,7 +230,7 @@ SQL end # only allow to use category itself id. new_record doesn't have a id. unless new_record? - match_id = /(\d+)-category/.match(self.slug) + match_id = /^(\d+)-category/.match(self.slug) errors.add(:slug, :invalid) if match_id && match_id[1] && match_id[1] != self.id.to_s end end