Commit graph

90 commits

Author SHA1 Message Date
Mark Felder
1bc845f9e4 Small optimization 2021-01-28 12:45:07 -06:00
feld
fb88baabac Apply 1 suggestion(s) to 1 file(s) 2021-01-28 11:25:29 -06:00
Mark Felder
75f68977af Add own trim functions that only strips one character
This makes it possible to support URLs that end in ) but are in another ()
2021-01-27 15:49:42 -06:00
Mark Felder
14e1f64a09 Missing operation for only trimming leading 2021-01-27 14:58:39 -06:00
Mark Felder
a7e86d3381 Credo 2021-01-27 14:42:05 -06:00
Mark Felder
aec97fac71 Split checks into functions returning atoms to make the decisions 2021-01-27 14:20:44 -06:00
Mark Felder
26fa3bffeb Try to make intelligent decisions when deciding if parens should be stripped before linking
This logic is torture and needs some rework.

Rules:

- Always strip leading (, as it can't be part of a URL
- Short circuit to only strip leading if no trailing
- If valid email address when trailing ) stripped, we can strip trailing )
- If not even a valid URL without trailing ), short circuit to only strip leading
- If query parameters detected, strip trailing. It should have been encoded as %29.
- If there isn't a / the trailing ) can't be part of the URL, strip trailing.
- If there isn't at least one ( in the URI.path, only strip leading. Assume ) is not part of the URL.
- If we have an equal count of ( and ) chars with the leading ( already stripped, only strip leading
2021-01-26 18:30:35 -06:00
Mark Felder
26fec6cff1 Fix invalid IPv4 linking; optimize
thx @href !
2020-12-19 13:20:11 -06:00
Haelwenn
9b86e5e5e4 Merge branch 'features/hostname_validation' into 'master'
Add .onion in the default TLDs, Validate IPv6, IDN compatibility in email and mentions

See merge request pleroma/elixir-libraries/linkify!29
2020-11-19 20:42:20 +00:00
Haelwenn
62b385674d Apply 1 suggestion(s) to 1 file(s) 2020-11-19 20:35:56 +00:00
Mark Felder
3ce2c34709 Fix linking URLs/domains with trailing punctuation 2020-11-19 18:55:17 +00:00
Haelwenn (lanodan) Monnier
649fc9125d parser: Validate IPv6, IDN compatibility in email and mentions 2020-11-19 17:42:34 +00:00
Haelwenn (lanodan) Monnier
26f5310379 parser: Add onion as an extra TLD 2020-11-19 17:42:34 +00:00
Justin Tormey
8713d4141a Add handle_href option for href pre-processing 2020-11-19 09:40:47 -06:00
Mark Felder
b87be206a7 Support URLs with FQDNs (trailing period on the tld) 2020-11-18 17:24:44 +00:00
Sergey Suprunenko
45e970d604
Upgrade credo 2020-11-16 23:18:32 +01:00
Sergey Suprunenko
2a050e1cbe
Ignore non-word chars in the beginning of mentions 2020-11-16 23:03:24 +01:00
Sergey Suprunenko
e16136f709
Do not parse mention if there is something before it 2020-11-10 21:24:50 +01:00
Sergey Suprunenko
c4b4cb95fb
Linkify.Parser.restore_stripped_symbols/3 must always return iodata 2020-10-06 21:49:01 +02:00
Sergey Suprunenko
7005cda9e4
Handle punctuation marks and new lines 2020-10-06 21:49:00 +02:00
Sergey Suprunenko
8d88833dc5
Remove unused clauses 2020-10-06 21:46:58 +02:00
Sergey Suprunenko
74afaca73b
Handle punctuation marks and angle bracket in the end of a link 2020-10-06 21:43:35 +02:00
Sergey Suprunenko
e5a8cf2b08
Do not parse html links inside html tags 2020-10-06 21:43:04 +02:00
Sergey Suprunenko
69902de571
Handle hashtags followed by skipped html tags 2020-08-31 20:48:04 +02:00
Justin Tormey
e720efd50c Accumulate as iodata, only convert to binary if necessary 2020-08-20 13:39:59 -05:00
Justin Tormey
61871d137a Reduce work for checking precense of type in opts 2020-07-27 13:37:15 -05:00
Justin Tormey
1d52bfeb81 Fix formatting 2020-07-27 12:46:26 -05:00
Justin Tormey
b1f6c04eef Add parser support for iodata and safe iodata 2020-07-27 12:42:51 -05:00
Alex Gleason
7c6cff9f8c
Don't parse mentions inside links
Fixes: https://git.pleroma.social/pleroma/pleroma/-/issues/1656
2020-06-30 16:29:32 -05:00
Egor Kislitsyn
14b8f39160 Disable strip_prefix by default 2019-07-11 20:08:30 +07:00
Egor Kislitsyn
66f5165655 Do not add class, target and rel attributes by default 2019-06-27 15:32:07 +07:00
Egor Kislitsyn
2690f2b680 Rename to Linkify 2019-06-24 17:57:31 +07:00
Egor Kislitsyn
093d2344d2 Refactor parser
Refactor parser
2019-06-21 20:09:52 +07:00
Egor Kislitsyn
76cfb574a3 Remove application configuration 2019-06-21 19:39:58 +07:00
Egor Kislitsyn
529014c8f4 Drop phone links support 2019-06-21 19:05:47 +07:00
Egor Kislitsyn
b044a63910 Add doc to valid_tld?/2 2019-06-21 18:27:01 +07:00
Egor Kislitsyn
150d9f222f Remove scheme setting 2019-06-21 18:09:52 +07:00
Egor Kislitsyn
f081e6b553 Remove markdown links support 2019-06-21 17:12:11 +07:00
rinpatch
70cbfdc84e Extend email? to utilize validate_tld 2019-06-18 13:25:44 +03:00
rinpatch
1a341fdac3 Move checking for validate_tld to valid_tld? 2019-06-18 13:07:14 +03:00
rinpatch
c19c7afa5b Refactor url?/2 to use opts 2019-06-18 12:57:31 +03:00
rinpatch
c8026cd16c Add an option to disable TLD validation
Added `validate_tld` option, which can be set to false to disable tld
validation and to :no_scheme to disable tld validation when a scheme is
present

Closes #8
2019-06-17 23:06:31 +03:00
Egor Kislitsyn
d9859f8aab Fix credo warnings 2019-06-12 15:33:03 +07:00
Egor Kislitsyn
cef4fe335c Improve parsing links inside parentheses and some refactoring 2019-06-12 15:27:18 +07:00
Egor Kislitsyn
0e6869c9ea Fix tld validation 2019-05-01 14:48:04 +07:00
Egor Kislitsyn
99c7ffdbe4 use MapSet instead of List 2019-04-09 18:44:05 +07:00
Egor Kislitsyn
32a6e41cd0 cleanup 2019-04-09 15:00:39 +07:00
Egor Kislitsyn
55636e8593 fix links inside nested html 2019-04-09 14:32:30 +07:00
Egor Kislitsyn
a6e8755863 do not link inside <pre> and <code> 2019-04-09 13:45:55 +07:00
Egor Kislitsyn
4949c02cb6 fix parsing inside HTML tags 2019-04-09 13:08:13 +07:00