Skip to content

Commit 91ba6ab

Browse files
committed
connected AllowedPostTitleFormattingTypes site setting to PostTitleScrubber
1 parent 88a75c1 commit 91ba6ab

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

app/helpers/posts_helper.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,23 @@ def max_title_length(_category)
8585
end
8686

8787
class PostTitleScrubber < Rails::HTML::PermitScrubber
88-
ALLOWED_ATTRS = %w[].freeze
89-
90-
ALLOWED_TAGS = %w[code em strong strike del sup sub kbd].freeze
91-
9288
def initialize
9389
super
94-
self.tags = ALLOWED_TAGS
95-
self.attributes = ALLOWED_ATTRS
90+
91+
attrs = []
92+
tags = []
93+
94+
allowed_types = SiteSetting['AllowedPostTitleFormattingTypes']
95+
tags.push('del', 'strike') if allowed_types.include?('strikethrough')
96+
tags << 'code' if allowed_types.include?('code')
97+
tags << 'kbd' if allowed_types.include?('keyboard')
98+
tags << 'em' if allowed_types.include?('italic')
99+
tags << 'strong' if allowed_types.include?('bold')
100+
tags << 'sub' if allowed_types.include?('subscript')
101+
tags << 'sup' if allowed_types.include?('superscript')
102+
103+
self.tags = tags
104+
self.attributes = attrs
96105
end
97106

98107
def skip_node?(node)

db/seeds/site_settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@
784784
- code
785785
- italic
786786
- keyboard
787+
- strikethrough
787788
- subscript
788789
- superscript
789790
value_type: array

0 commit comments

Comments
 (0)