forgejo/modules/markup
mrsdizzie 6293736d02 Use stricter boundaries for auto-link detection (#6522)
* Use stricter boundaries for auto-link detection

Currently autolinks use \W for boundary detection which creates many
situations of inserting links into places they don't belong (paths,
URLs, UUIDs, etc...)

This fixes that by replacing \W and only allowing these matches to touch
an open paren or bracket (matching what seems to be Github behavior) in
addition to whitespace and start of line. Similar for ending boundary as
well.

Fixes #6149
(and probably others)

* Update test

Replace incorrect test with a value that is a valid username, based on:

"Username should contain only alphanumeric, dash ('-'), underscore ('_')
and dot ('.') characters."

* Also allow for period at the end

Matching Github behavior

* Fix email regex to work properly with specificed boundaries

Create a specific capture group for email address and then use
FindStringSubmatchIndex to allow for non-matching patterns as
boundaries.

* Add Tests

Add tests for new behavior -- including tests for email addresses which
were absent before.
2019-04-07 12:18:16 +01:00
..
csv Add csv file render support defaultly (#4105) 2018-07-21 00:08:15 +03:00
external Better logging (#6038) (#6095) 2019-04-02 08:48:31 +01:00
markdown Markdown: enable some more extensions (#6362) 2019-03-21 15:53:06 +02:00
orgmode Better logging (#6038) (#6095) 2019-04-02 08:48:31 +01:00
html.go Use stricter boundaries for auto-link detection (#6522) 2019-04-07 12:18:16 +01:00
html_internal_test.go Use stricter boundaries for auto-link detection (#6522) 2019-04-07 12:18:16 +01:00
html_test.go Use stricter boundaries for auto-link detection (#6522) 2019-04-07 12:18:16 +01:00
markup.go Better logging (#6038) (#6095) 2019-04-02 08:48:31 +01:00
markup_test.go Prioritize "readme.md" (#5691) 2019-01-14 14:15:06 -05:00
sanitizer.go Restructure markup & markdown to prepare for multiple markup language… (#2411) 2017-09-16 20:17:57 +03:00
sanitizer_test.go Restructure markup & markdown to prepare for multiple markup language… (#2411) 2017-09-16 20:17:57 +03:00