diff options
author | Vitaly Ovchinnikov <v@postbox.nz> | 2023-09-12 21:19:12 +0000 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-09-19 01:20:11 +0200 |
commit | 8f15b804d1a760d4f4e5c0c47a8a26ee2c04a830 (patch) | |
tree | 12926fa183e53a65154b16e767e524feaeff490a /lib/parse/hyperlinks_test.go | |
parent | d57aa9e582f1644e2ee260c5c18fbf974dcc03ee (diff) | |
download | aerc-8f15b804d1a760d4f4e5c0c47a8a26ee2c04a830.tar.gz |
hyperlinks: better parsing of emails without mailto prefixes
Add some new tests from the emails I have and make them work by
adjusting the code that looks for hyperlinks.
The idea is to treat "inline" emails (those without mailto:) a little
bit different and stop a little earlier while looking for their ends.
Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/parse/hyperlinks_test.go')
-rw-r--r-- | lib/parse/hyperlinks_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/parse/hyperlinks_test.go b/lib/parse/hyperlinks_test.go index cedad648..00a06764 100644 --- a/lib/parse/hyperlinks_test.go +++ b/lib/parse/hyperlinks_test.go @@ -114,6 +114,26 @@ func TestHyperlinks(t *testing.T) { text: "You can reach me via the somewhat strange, but nonetheless valid, email mailto:~mpldr/list@[2001:db8::7]?subject=whazzup%3F", links: []string{"mailto:~mpldr/list@[2001:db8::7]?subject=whazzup%3F"}, }, + { + name: "simple email in <a href>", + text: `<a href="mailto:a@abc.com" rel="noopener noreferrer">`, + links: []string{"mailto:a@abc.com"}, + }, + { + name: "simple email in <a> body", + text: `<a href="#" rel="noopener noreferrer">a@abc.com</a><br/><p>more text</p>`, + links: []string{"mailto:a@abc.com"}, + }, + { + name: "emails in <a> href and body", + text: `<a href="mailto:a@abc.com" rel="noopener noreferrer">b@abc.com</a><br/><p>more text</p>`, + links: []string{"mailto:a@abc.com", "mailto:b@abc.com"}, + }, + { + name: "email in <...>", + text: `<div>01.02.2023, 10:11, "Firstname Lastname" <a@abc.com>:</div>`, + links: []string{"mailto:a@abc.com"}, + }, } for i, test := range tests { |