validate markdown_linkify_tlds setting (#16485)

Prevent adding * as a value to markdown_linkify_tlds site setting
This commit is contained in:
Isaac Janzen 2022-04-15 10:14:28 -05:00 committed by GitHub
parent 461936f211
commit ee9daec36f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -2404,6 +2404,7 @@ en:
leading_trailing_slash: "The regular expression must not start and end with a slash."
unicode_usernames_avatars: "The internal system avatars do not support Unicode usernames."
list_value_count: "The list must contain exactly %{count} values."
markdown_linkify_tlds: "You cannot include a value of '*'."
google_oauth2_hd_groups: "You must first set 'google oauth2 hd' before enabling this setting."
search_tokenize_chinese_enabled: "You must disable 'search_tokenize_chinese' before enabling this setting."
search_tokenize_japanese_enabled: "You must disable 'search_tokenize_japanese' before enabling this setting."

View File

@ -847,6 +847,7 @@ posting:
type: list
default: "com|net|org|io|onion|co|tv|ru|cn|us|uk|me|de|fr|fi|gov"
list_type: compact
validator: "MarkdownLinkifyTldsValidator"
markdown_typographer_quotation_marks:
client: true
type: list

View File

@ -0,0 +1,16 @@
# frozen_string_literal: true
class MarkdownLinkifyTldsValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(value)
!value.include?("*")
end
def error_message
I18n.t("site_settings.errors.markdown_linkify_tlds")
end
end