From c6c7c6223d92fb43033735d2b754dd360feaf3d9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 10 Nov 2022 21:09:03 +0100 Subject: Change verification to only work for https links (#20304) Fix #20242 --- app/models/account/field.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/account/field.rb') diff --git a/app/models/account/field.rb b/app/models/account/field.rb index d74f90b2b..e84a0eeb1 100644 --- a/app/models/account/field.rb +++ b/app/models/account/field.rb @@ -3,7 +3,7 @@ class Account::Field < ActiveModelSerializers::Model MAX_CHARACTERS_LOCAL = 255 MAX_CHARACTERS_COMPAT = 2_047 - ACCEPTED_SCHEMES = %w(http https).freeze + ACCEPTED_SCHEMES = %w(https).freeze attributes :name, :value, :verified_at, :account -- cgit From 96f51e593f2609579b8155d971bcbc5ab9e7cd4c Mon Sep 17 00:00:00 2001 From: Emily Strickland Date: Fri, 11 Nov 2022 12:22:28 -0800 Subject: Guard against error extracting `body` from URL (#20428) If `Nokogiri::HTML(value).at_xpath('//body')` fails to find the `body` element, it will return `nil`. We can guard against that with an early return. Avoids calling `children` on `Nilclass` in those cases. --- app/models/account/field.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/models/account/field.rb') diff --git a/app/models/account/field.rb b/app/models/account/field.rb index e84a0eeb1..ffc8dce80 100644 --- a/app/models/account/field.rb +++ b/app/models/account/field.rb @@ -76,6 +76,7 @@ class Account::Field < ActiveModelSerializers::Model def extract_url_from_html doc = Nokogiri::HTML(value).at_xpath('//body') + return if doc.nil? return if doc.children.size > 1 element = doc.children.first -- cgit