feat: remove colon and semicolons when sanitizing inbox name (#11889)
This commit is contained in:
@@ -191,7 +191,7 @@ class Inbox < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def apply_sanitization_rules(name)
|
def apply_sanitization_rules(name)
|
||||||
name.gsub(/[\\<>@"!#$%&*+=?^`{|}~]/, '') # Remove forbidden chars
|
name.gsub(/[\\<>@"!#$%&*+=?^`{|}~:;]/, '') # Remove forbidden chars
|
||||||
.gsub(/[\x00-\x1F\x7F]/, ' ') # Replace control chars with spaces
|
.gsub(/[\x00-\x1F\x7F]/, ' ') # Replace control chars with spaces
|
||||||
.gsub(/\A[[:punct:]]+|[[:punct:]]+\z/, '') # Remove leading/trailing punctuation
|
.gsub(/\A[[:punct:]]+|[[:punct:]]+\z/, '') # Remove leading/trailing punctuation
|
||||||
.gsub(/\s+/, ' ') # Normalize spaces
|
.gsub(/\s+/, ' ') # Normalize spaces
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ RSpec.describe Inbox do
|
|||||||
describe '#sanitized_name' do
|
describe '#sanitized_name' do
|
||||||
context 'when inbox name contains forbidden characters' do
|
context 'when inbox name contains forbidden characters' do
|
||||||
it 'removes forbidden and spam-trigger characters' do
|
it 'removes forbidden and spam-trigger characters' do
|
||||||
inbox = FactoryBot.build(:inbox, name: 'Test/Name\\With<Bad>@Characters"And\'Quotes!#$%')
|
inbox = FactoryBot.build(:inbox, name: 'Test/Name\\With<Bad>@Characters"And\';:Quotes!#$%')
|
||||||
expect(inbox.sanitized_name).to eq('Test/NameWithBadCharactersAnd\'Quotes')
|
expect(inbox.sanitized_name).to eq('Test/NameWithBadCharactersAnd\'Quotes')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user