]> cat aescling's git repositories - mastodon.git/commitdiff
Add support for Gemini urls (#15013)
authorJosh Leeb-du Toit <mail@joshleeb.com>
Mon, 19 Oct 2020 15:02:13 +0000 (02:02 +1100)
committerGitHub <noreply@github.com>
Mon, 19 Oct 2020 15:02:13 +0000 (17:02 +0200)
This PR updates the `valid_url` regex and sanitizer allowlist to provide
support for Gemini urls.

Closes #14991

app/lib/sanitize_config.rb
config/initializers/twitter_regex.rb

index 4ad1199a60442c9788d8c731e963ff31cfd1a62b..8f700197b272a88dc9f6fb1a2bec49b1465b1cfe 100644 (file)
@@ -18,6 +18,7 @@ class Sanitize
       gopher
       xmpp
       magnet
+      gemini
     ).freeze
 
     CLASS_WHITELIST_TRANSFORMER = lambda do |env|
index f84f7c0cbb62caca001a0d2a34fd992f7ad8e9ad..7f99a0005649e6f9b6c74e2676a1011831c57df4 100644 (file)
@@ -29,7 +29,7 @@ module Twitter
       (                                                                                     #   $1 total match
         (#{REGEXEN[:valid_url_preceding_chars]})                                            #   $2 Preceding character
         (                                                                                   #   $3 URL
-          ((?:https?|dat|dweb|ipfs|ipns|ssb|gopher):\/\/)?                                  #   $4 Protocol (optional)
+          ((?:https?|dat|dweb|ipfs|ipns|ssb|gopher|gemini):\/\/)?                           #   $4 Protocol (optional)
           (#{REGEXEN[:valid_domain]})                                                       #   $5 Domain(s)
           (?::(#{REGEXEN[:valid_port_number]}))?                                            #   $6 Port number (optional)
           (/#{REGEXEN[:valid_url_path]}*)?                                                  #   $7 URL Path and anchor