6 Commits

Author SHA1 Message Date
Karel Balej
02324e9d9c lib: disallow < in URLs when parsing HTML
Make sure that links placed verbatim inside HTML elements' bodies are
not parsed along with adjacent HTML tags as illustrated in the new test
case.

Also change the existing code to use the idiomatic Go way to get a
set-like functionality.

Changelog-fixed: Parsed links in HTML message parts now do not include
 trailing HTML tags.
Signed-off-by: Karel Balej <balejk@matfyz.cz>
Tested-by: Jakub Růžička <jakub.ruzicka@matfyz.cz>
2025-02-04 15:18:01 +01:00
Vitaly Ovchinnikov
8f15b804d1 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>
2023-09-19 01:20:11 +02:00
Robin Jarry
9cbfb190f6 parse-links: be more strict with url parsing
Reuse the same logic than colorize.c to allow parsing markdown links.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-06-25 22:53:19 +02:00
Moritz Poldrack
fad90c2956 open-link: make URL parsing more lenient
URLs are extremely loosely defined and can take many shapes which may
not be parsed at all if unusual characters like the exclamation mark are
present. To ensure lists and odd use of spaces are not parsed as links
some sanity-checks are in place:
	- the URL's schema must be at least two characters long
	- the URL's authority, path, and fragment must have a combined
	  length of 8 characters or longer
	- the URL must not contain a whitespace character, >, ), or "
	- the URL may only contain a ] when followed by a different allowed
	  character or at the end of the line (necessary for IPv6
	  authorities)

The tests for this function now include links with an exclamation point
and IPv6 addresses. The tests are given names to be easier identifiable.

Link: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
Reported-by: "Bence Ferdinandy" <bence@ferdinandy.com>
Cc: "Koni Marti" <koni.marti@gmail.com>
Fixes: e1d8bc4d17 ("msgviewer: open http links from messages")
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2022-09-13 23:58:53 +02:00
Moritz Poldrack
aaf0a0c656 lint: apply new formatting rules
Run `make fmt`.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:44:52 +02:00
Koni Marti
e1d8bc4d17 msgviewer: open http links from messages
Parse http links from a message and display them as completions in the
:open-link command.

Add the following binds to the [view] section in your binds.conf:
<C-l> = :open-link <space>

Parsing can be disabled in aerc.conf by setting parse-http-links to
false in the viewer section.

Thanks to Moritz for the help with the regular expression.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Reviewed-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-14 22:12:48 +02:00