FIX: truncate extremely long site name titles (#30977)

This corrects an issue where very long titles on
website would cause the backup not to save
cause filename was too long
This commit is contained in:
Sam 2025-01-24 15:47:05 +11:00 committed by GitHub
parent 8d45755a06
commit 8be16c997e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -75,7 +75,7 @@ module BackupRestore
end end
def get_parameterized_title def get_parameterized_title
SiteSetting.title.parameterize.presence || "discourse" SiteSetting.title.parameterize[...64].presence || "discourse"
end end
def initialize_state def initialize_state

View File

@ -9,6 +9,13 @@ RSpec.describe BackupRestore::Backuper do
expect(backuper.send(:get_parameterized_title)).to eq("discourse") expect(backuper.send(:get_parameterized_title)).to eq("discourse")
end end
it "truncates the title to 64 chars" do
SiteSetting.title = "This is th title of a very long site that is going to be truncated"
backuper = BackupRestore::Backuper.new(Discourse.system_user.id)
expect(backuper.send(:get_parameterized_title).length).to eq(64)
end
it "returns a valid parameterized site title" do it "returns a valid parameterized site title" do
SiteSetting.title = "Coding Horror" SiteSetting.title = "Coding Horror"
backuper = BackupRestore::Backuper.new(Discourse.system_user.id) backuper = BackupRestore::Backuper.new(Discourse.system_user.id)