mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 04:31:56 +08:00
76ab0350f1
When an admin changes the site setting slug_generation_method to encoded, we weren't really encoding the slug, but just allowing non-ascii characters in the slug (unicode). That brings problems when a user posts a link to topic without the slug, as our topic controller tries to redirect the user to the correct URL that contains the slug with unicode characters. Having unicode in the Location header in a response is a RFC violation and some browsers end up in a redirection loop. Bug report: https://meta.discourse.org/t/-/125371?u=falco This commit also checks if a site uses encoded slugs and clear all saved slugs in the db so they can be regenerated using an onceoff job.
15 lines
321 B
Ruby
15 lines
321 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
|
|
class FixEncodedTopicSlugs < ::Jobs::Onceoff
|
|
def execute_onceoff(args)
|
|
return unless SiteSetting.slug_generation_method == 'encoded'
|
|
|
|
#Make all slugs nil and let the app regenerate with proper encoded ones
|
|
Topic.update_all(slug: nil)
|
|
end
|
|
end
|
|
|
|
end
|