1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-11 20:18:20 +00:00

Replace linkRegex with xurls library (#6261)

* Replace linkRegex with xurls library

Rather than maintaining a complicated regex to match URLs for
autolinking, gitea can use this existing go library that takes care of
the matching with very little code change to gitea itself. After
spending a while trying to find the perfect regex for all cases this library
still works better as it is more flexible than a single regex ever will be.

This will also fix the following issues: #5844 #3095 #3381

This passes all our current tests and I've added new ones mentioned in
those issues as well.

* Use xurls.StrictMatchingScheme instead of xurls.Strict

This is much faster and we only care about https? links to preserve
existing behavior.
This commit is contained in:
mrsdizzie
2019-03-07 15:12:01 -05:00
committed by techknowlogick
parent 01bd1fcd33
commit f2de5dc8c8
9 changed files with 2038 additions and 3 deletions

9
Gopkg.lock generated
View File

@@ -725,6 +725,14 @@
pruneopts = "NUT"
revision = "02ccfbfaf0cc627aa3aec8ef7ed5cfeec5b43f63"
[[projects]]
digest = "1:63953ffb90bbc880c612d576fcfd973a5904277d25ec9e2d8d5719bf67969662"
name = "github.com/mvdan/xurls"
packages = ["."]
pruneopts = "NUT"
revision = "e52e821cbfe8fe163ff6f8628ab5869b11fc05af"
version = "v2.0.0"
[[projects]]
digest = "1:2be1d891535ce3d6d2a3db9087f07415e909744e9eff1a30f8f0b2519df60ae6"
name = "github.com/nfnt/resize"
@@ -1293,6 +1301,7 @@
"github.com/mcuadros/go-version",
"github.com/microcosm-cc/bluemonday",
"github.com/msteinert/pam",
"github.com/mvdan/xurls",
"github.com/nfnt/resize",
"github.com/pquerna/otp",
"github.com/pquerna/otp/totp",