about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/services/verify_link_service.rb2
-rw-r--r--spec/services/verify_link_service_spec.rb15
2 files changed, 16 insertions, 1 deletions
diff --git a/app/services/verify_link_service.rb b/app/services/verify_link_service.rb
index 9da7f93c3..846751cd5 100644
--- a/app/services/verify_link_service.rb
+++ b/app/services/verify_link_service.rb
@@ -27,6 +27,6 @@ class VerifyLinkService < BaseService
   def link_back_present?
     return false if @body.empty?
 
-    Nokogiri::HTML(@body).xpath('//a[@rel="me"]|//link[@rel="me"]').any? { |link| link['href'] == @link_back }
+    Nokogiri::HTML(@body).xpath('//a[contains(concat(" ", normalize-space(@rel), " "), " me ")]|//link[contains(concat(" ", normalize-space(@rel), " "), " me ")]').any? { |link| link['href'] == @link_back }
   end
 end
diff --git a/spec/services/verify_link_service_spec.rb b/spec/services/verify_link_service_spec.rb
index 8ce867e9d..acd4e851e 100644
--- a/spec/services/verify_link_service_spec.rb
+++ b/spec/services/verify_link_service_spec.rb
@@ -26,6 +26,21 @@ RSpec.describe VerifyLinkService, type: :service do
     end
   end
 
+  context 'when a link contains an <a rel="noopener"> back' do
+    let(:html) do
+      <<-HTML
+        <!doctype html>
+        <body>
+          <a href="#{ActivityPub::TagManager.instance.url_for(account)}" rel="noopener me" target="_blank">Follow me on Mastodon</a>
+        </body>
+      HTML
+    end
+
+    it 'marks the field as verified' do
+      expect(field.verified?).to be true
+    end
+  end
+
   context 'when a link contains a <link> back' do
     let(:html) do
       <<-HTML