From f2e0d5b634324a2981bd63105fb7797506afd2e6 Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 21 Mar 2023 22:09:38 +0900 Subject: [PATCH] Fix activitypub link href checker to ignore no-url --- lib/sanitize_ext/sanitize_config.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index fdcb0c450b..f538ca95b6 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -54,11 +54,14 @@ class Sanitize return unless env[:node_name] == 'a' current_node = env[:node] - href = current_node['href'] + href = current_node['href'] || '' text = current_node.text cls = current_node['class'] || '' - scheme = if current_node['href'] =~ Sanitize::REGEX_PROTOCOL + dot_pos = text.index('.') + return unless dot_pos.present? && dot_pos > 0 && dot_pos < text.size - 1 + + scheme = if href =~ Sanitize::REGEX_PROTOCOL Regexp.last_match(1).downcase else :relative