Skip to content

Commit 4ee3ba4

Browse files
committed
Merge branch 'release/v1.20.4'
2 parents c84bfc3 + 84e46e6 commit 4ee3ba4

File tree

10 files changed

+183
-100
lines changed

10 files changed

+183
-100
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2727
restore-keys: |
2828
${{ runner.os }}-go-
29-
- run: go test -p 1 ./internal/storage ./server ./server/pop3 ./internal/tools ./internal/html2text -v
29+
- run: go test -p 1 ./internal/storage ./server ./server/pop3 ./internal/tools ./internal/html2text ./internal/linkcheck -v
3030
- run: go test -p 1 ./internal/storage ./internal/html2text -bench=.
3131

3232
# build the assets

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
Notable changes to Mailpit will be documented in this file.
44

5+
## [v1.20.4]
6+
7+
### Chore
8+
- Update Go modules
9+
- Update node modules
10+
- Upgrade vue-css-donut-chart & related charts
11+
12+
### Fix
13+
- Relax URL detection in link check tool ([#357](https://github.com/axllent/mailpit/issues/357))
14+
15+
516
## [v1.20.3]
617

718
### Chore

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/tg123/go-htpasswd v1.2.2
2626
github.com/vanng822/go-premailer v1.21.0
2727
golang.org/x/net v0.28.0
28-
golang.org/x/text v0.17.0
28+
golang.org/x/text v0.18.0
2929
golang.org/x/time v0.6.0
3030
gopkg.in/yaml.v3 v3.0.1
3131
modernc.org/sqlite v1.32.0
@@ -55,8 +55,8 @@ require (
5555
github.com/valyala/bytebufferpool v1.0.0 // indirect
5656
github.com/vanng822/css v1.0.1 // indirect
5757
golang.org/x/crypto v0.26.0 // indirect
58-
golang.org/x/image v0.19.0 // indirect
59-
golang.org/x/sys v0.24.0 // indirect
58+
golang.org/x/image v0.20.0 // indirect
59+
golang.org/x/sys v0.25.0 // indirect
6060
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
6161
modernc.org/gc/v3 v3.0.0-20240801135723-a856999a2e4a // indirect
6262
modernc.org/libc v1.60.1 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf
128128
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
129129
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
130130
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
131-
golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ=
132-
golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys=
131+
golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw=
132+
golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM=
133133
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
134134
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
135135
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
@@ -161,8 +161,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
161161
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
162162
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
163163
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
164-
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
165-
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
164+
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
165+
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
166166
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
167167
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
168168
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
@@ -176,8 +176,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
176176
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
177177
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
178178
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
179-
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
180-
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
179+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
180+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
181181
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
182182
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
183183
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

internal/linkcheck/linkcheck_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package linkcheck
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
7+
"github.com/axllent/mailpit/internal/storage"
8+
)
9+
10+
var (
11+
testHTML = `
12+
<html>
13+
<head>
14+
<link rel=stylesheet href="http://remote-host/style.css"></link>
15+
<script async src="https://www.googletagmanager.com/gtag/js?id=ignored"></script>
16+
</head>
17+
<body>
18+
<div>
19+
<p><a href="http://example.com">HTTP link</a></p>
20+
<p><a href="https://example.com">HTTPS link</a></p>
21+
<p><a href="HTTPS://EXAMPLE.COM">HTTPS link</a></p>
22+
<p><a href="http://localhost">Localhost link</a> (ignored)</p>
23+
<p><a href="https://localhost">Localhost link</a> (ignored)</p>
24+
<p><a href='https://127.0.0.1'>Single quotes link</a> (ignored)</p>
25+
<p><img src=https://example.com/image.jpg></p>
26+
<p href="http://invalid-link.com">This should be ignored</p>
27+
<p><a href="http://link with spaces">Link with spaces</a></p>
28+
<p><a href="http://example.com/?blaah=yes&amp;test=true">URL-encoded characters</a></p>
29+
</div>
30+
</body>
31+
</html>`
32+
33+
expectedHTMLLinks = []string{
34+
"http://example.com", "https://example.com", "HTTPS://EXAMPLE.COM", "http://localhost", "https://localhost", "https://127.0.0.1", "http://link with spaces", "http://example.com/?blaah=yes&test=true",
35+
"http://remote-host/style.css", // css
36+
"https://example.com/image.jpg", // images
37+
}
38+
39+
testTextLinks = `This is a line with http://example.com https://example.com
40+
HTTPS://EXAMPLE.COM
41+
[http://localhost]
42+
www.google.com < ignored
43+
|||http://example.com/?some=query-string|||
44+
`
45+
46+
expectedTextLinks = []string{
47+
"http://example.com", "https://example.com", "HTTPS://EXAMPLE.COM", "http://localhost", "http://example.com/?some=query-string",
48+
}
49+
)
50+
51+
func TestLinkDetection(t *testing.T) {
52+
53+
t.Log("Testing HTML link detection")
54+
55+
m := storage.Message{}
56+
57+
m.Text = testTextLinks
58+
m.HTML = testHTML
59+
60+
textLinks := extractTextLinks(&m)
61+
62+
if !reflect.DeepEqual(textLinks, expectedTextLinks) {
63+
t.Fatalf("Failed to detect text links correctly")
64+
}
65+
66+
htmlLinks := extractHTMLLinks(&m)
67+
68+
if !reflect.DeepEqual(htmlLinks, expectedHTMLLinks) {
69+
t.Fatalf("Failed to detect HTML links correctly")
70+
}
71+
}

internal/linkcheck/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/axllent/mailpit/internal/tools"
1111
)
1212

13-
var linkRe = regexp.MustCompile(`(?m)\b(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:'!\/~+#-]*[\w@?^=%&\/~+#-])`)
13+
var linkRe = regexp.MustCompile(`(?im)\b(http|https):\/\/([\-\w@:%_\+'!.~#?,&\/\/=;]+)`)
1414

1515
// RunTests will run all tests on an HTML string
1616
func RunTests(msg *storage.Message, followRedirects bool) (Response, error) {

0 commit comments

Comments
 (0)