Skip to content

Commit

Permalink
Better normalisation of links for comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrob committed Jan 30, 2024
1 parent 605b9be commit 818936e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/IMAPLinkDestinationRevealer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def edit_message(self, byte_message):

href_url = link_prefix + link_url
text_url = b'http' + link_text
if href_url not in [text_url, b'%s/' % text_url, text_url.rstrip(b'/')]:
if self.normalise_url(href_url) != self.normalise_url(text_url):
parts = link_url.split(b'/', 1)
truncated = b'%s%s' % (link_prefix, parts[0])
if len(parts) > 0:
Expand All @@ -55,3 +55,7 @@ def edit_message(self, byte_message):
else:
# no links to replace (or potentially some encoding not handled by IMAPMessageEditor)
return byte_message

@staticmethod
def normalise_url(url):
return url.rstrip(b'/').replace(b'&', b'&')

0 comments on commit 818936e

Please sign in to comment.