lib/ahoy_email/processor.rb in ahoy_email-1.1.0 vs lib/ahoy_email/processor.rb in ahoy_email-1.1.1
- old
+ new
@@ -82,10 +82,11 @@
def track_links
if html_part?
part = message.html_part || message
+ # TODO use Nokogiri::HTML::DocumentFragment.parse in 2.0
doc = Nokogiri::HTML(part.body.raw_source)
doc.css("a[href]").each do |link|
uri = parse_uri(link["href"])
next unless trackable?(uri)
# utm params first
@@ -113,9 +114,15 @@
signature: signature
)
end
end
+ # ampersands converted to &
+ # https://github.com/sparklemotion/nokogiri/issues/1127
+ # not ideal, but should be equivalent in html5
+ # https://stackoverflow.com/questions/15776556/whats-the-difference-between-and-amp-in-html5
+ # escaping technically required before html5
+ # https://stackoverflow.com/questions/3705591/do-i-encode-ampersands-in-a-href
part.body = doc.to_s
end
end
def html_part?