about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-10 09:36:47 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-10 09:36:47 +0100
commitc118918520c3c5b1d60451e9692c45f7bd7e32e4 (patch)
treed192e63c8f2599c44189fbb3bc33b481e22fe28b /app/lib
parentb2a25d446a9f4368ad9d1240b9da30bc33942da5 (diff)
parent8fdbb4d00d371e7a900bec3a262216d95a784d52 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/models/custom_emoji.rb`:
  Not a real conflict, just upstream changing a line too close to
  a glitch-soc-specific validation.
  Applied upstream changes.
- `app/models/public_feed.rb`:
  Not a real conflict, just upstream changing a line too close to
  a glitch-soc-specific parameter documentation.
  Applied upstream changes.
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/hashtag_normalizer.rb2
-rw-r--r--app/lib/request.rb3
2 files changed, 3 insertions, 2 deletions
diff --git a/app/lib/hashtag_normalizer.rb b/app/lib/hashtag_normalizer.rb
index c1f99e163..49fa6101d 100644
--- a/app/lib/hashtag_normalizer.rb
+++ b/app/lib/hashtag_normalizer.rb
@@ -8,7 +8,7 @@ class HashtagNormalizer
   private
 
   def remove_invalid_characters(str)
-    str.gsub(/[^[:alnum:]#{Tag::HASHTAG_SEPARATORS}]/, '')
+    str.gsub(Tag::HASHTAG_INVALID_CHARS_RE, '')
   end
 
   def ascii_folding(str)
diff --git a/app/lib/request.rb b/app/lib/request.rb
index 1ea86862d..dd198f399 100644
--- a/app/lib/request.rb
+++ b/app/lib/request.rb
@@ -199,7 +199,8 @@ class Request
         rescue IPAddr::InvalidAddressError
           Resolv::DNS.open do |dns|
             dns.timeouts = 5
-            addresses = dns.getaddresses(host).take(2)
+            addresses = dns.getaddresses(host)
+            addresses = addresses.filter { |addr| addr.is_a?(Resolv::IPv6) }.take(2) + addresses.filter { |addr| !addr.is_a?(Resolv::IPv6) }.take(2)
           end
         end