A platform for community discussion. Free, open, simple.
validate markdown_linkify_tlds setting (#16485)
Isaac Janzenee9daec36faf
diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 92b0f58b587..dfd396f1ed1 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -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."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex bbfa5ed6408..4e4c836b142 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -847,6 +847,7 @@ posting:type: listdefault: "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: truetype: listdiff --git a/lib/validators/markdown_linkify_tlds_validator.rb b/lib/validators/markdown_linkify_tlds_validator.rbnew file mode 100644index 00000000000..fbde2026226--- /dev/null+++ b/lib/validators/markdown_linkify_tlds_validator.rb@@ -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