FIX: truncate extremely long site name titles ()

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
lib/backup_restore
spec/lib/backup_restore

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

@ -9,6 +9,13 @@ RSpec.describe BackupRestore::Backuper do
expect(backuper.send(:get_parameterized_title)).to eq("discourse")
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
SiteSetting.title = "Coding Horror"
backuper = BackupRestore::Backuper.new(Discourse.system_user.id)