From 6d970d6e7144017a8cb7d30d28cd0db4df227fb7 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Wed, 19 Sep 2018 23:47:31 +0900 Subject: [PATCH] Fix failed profile verification when rel attribute including values other than me (#8733) --- app/services/verify_link_service.rb | 2 +- spec/services/verify_link_service_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/services/verify_link_service.rb b/app/services/verify_link_service.rb index 9da7f93c39..846751cd59 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 8ce867e9d4..acd4e851e5 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 back' do + let(:html) do + <<-HTML + + + Follow me on Mastodon + + HTML + end + + it 'marks the field as verified' do + expect(field.verified?).to be true + end + end + context 'when a link contains a back' do let(:html) do <<-HTML