Fix #3225: Exception in NoteSanitizer#relativize_links.

This commit is contained in:
evazion
2017-07-19 21:13:04 -05:00
parent 8dafa15069
commit 1fe6a5fc65
2 changed files with 10 additions and 4 deletions

View File

@@ -79,14 +79,15 @@ module NoteSanitizer
end
def self.relativize_links(node:, **env)
return unless node.name == "a" && node.attribute("href")
return unless node.name == "a" && node["href"].present?
href = node.attribute("href")
url = Addressable::URI.parse(href.value).normalize
url = Addressable::URI.heuristic_parse(node["href"]).normalize
if url.authority.in?(Danbooru.config.hostnames)
url.site = nil
href.value = url.to_s
node["href"] = url.to_s
end
rescue Addressable::URI::InvalidURIError
# do nothing for invalid urls
end
end