dmails: fix bug with parsing wiki links in email notifications.

Bug: sending a dmail containing a wiki link (ex: [[tagme]]) failed when
the recipient had email notifications turned on.

Cause: wiki links inside email notifications use absolute urls, which
the dtext postprocessor didn't parse correctly.
This commit is contained in:
evazion
2019-11-05 19:10:41 -06:00
parent a653513e0a
commit 06d0ceb016
3 changed files with 9 additions and 3 deletions

View File

@@ -28,7 +28,8 @@ class DText
fragment = Nokogiri::HTML.fragment(html)
fragment.css("a.dtext-wiki-link").each do |node|
name = node["href"][%r!\A/wiki_pages/(.*)\z!i, 1]
path = Addressable::URI.parse(node["href"]).path
name = path[%r!\A/wiki_pages/(.*)\z!i, 1]
name = CGI.unescape(name)
name = WikiPage.normalize_title(name)
wiki = wiki_pages.find { |wiki| wiki.title == name }