mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 12:38:21 -05:00
FIX: Make category slugs lowercase (#11277)
Admins could specify category slug with upper case characters and same slug, but with different cases could be used simultaneously.
This commit is contained in:
@@ -343,8 +343,7 @@ class Category < ActiveRecord::Base
|
||||
if slug.present?
|
||||
# if we don't unescape it first we strip the % from the encoded version
|
||||
slug = SiteSetting.slug_generation_method == 'encoded' ? CGI.unescape(self.slug) : self.slug
|
||||
# sanitize the custom slug
|
||||
self.slug = Slug.sanitize(slug)
|
||||
self.slug = Slug.for(slug, '', method: :encoded)
|
||||
|
||||
if self.slug.blank?
|
||||
errors.add(:slug, :invalid)
|
||||
@@ -795,8 +794,12 @@ class Category < ActiveRecord::Base
|
||||
return nil if slug_path.empty?
|
||||
return nil if slug_path.size > SiteSetting.max_category_nesting
|
||||
|
||||
if SiteSetting.slug_generation_method == "encoded"
|
||||
slug_path.map! { |slug| CGI.escape(slug) }
|
||||
slug_path.map! do |slug|
|
||||
if SiteSetting.slug_generation_method == "encoded"
|
||||
CGI.escape(slug.downcase)
|
||||
else
|
||||
slug.downcase
|
||||
end
|
||||
end
|
||||
|
||||
query =
|
||||
|
||||
Reference in New Issue
Block a user