Skip to content

Commit 6d16a25

Browse files
authored
Merge branch 'main' into improve-profile-in-org
2 parents dbc1bdf + 61ff91f commit 6d16a25

File tree

7 files changed

+34
-14
lines changed

7 files changed

+34
-14
lines changed

modules/markup/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var (
6666
// well as the HTML5 spec:
6767
// http://spec.commonmark.org/0.28/#email-address
6868
// https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type%3Demail)
69-
emailRegex = regexp.MustCompile("(?:\\s|^|\\(|\\[)([a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9]{2,}(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)(?:\\s|$|\\)|\\]|\\.(\\s|$))")
69+
emailRegex = regexp.MustCompile("(?:\\s|^|\\(|\\[)([a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9]{2,}(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+)(?:\\s|$|\\)|\\]|;|,|\\?|!|\\.(\\s|$))")
7070

7171
// blackfriday extensions create IDs like fn:user-content-footnote
7272
blackfridayExtRegex = regexp.MustCompile(`[^:]*:user-content-`)

modules/markup/html_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ func TestRender_email(t *testing.T) {
264264
"send email to [email protected].",
265265
`<p>send email to <a href="mailto:[email protected]" rel="nofollow">[email protected]</a>.</p>`)
266266

267+
test(
268+
269+
270+
271+
272+
273+
`<p><a href="mailto:[email protected]" rel="nofollow">[email protected]</a>,<br/>
274+
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>.<br/>
275+
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>;<br/>
276+
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>?<br/>
277+
<a href="mailto:[email protected]" rel="nofollow">[email protected]</a>!</p>`)
278+
267279
// Test that should *not* be turned into email links
268280
test(
269281

modules/markup/orgmode/orgmode.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (r *Writer) WriteRegularLink(l org.RegularLink) {
158158
case "image":
159159
if l.Description == nil {
160160
imageSrc := getMediaURL(link)
161-
fmt.Fprintf(r, `<img src="%s" alt="%s" title="%s" />`, imageSrc, link, link)
161+
fmt.Fprintf(r, `<img src="%s" alt="%s" />`, imageSrc, link)
162162
} else {
163163
description := strings.TrimPrefix(org.String(l.Description...), "file:")
164164
imageSrc := getMediaURL([]byte(description))
@@ -167,18 +167,18 @@ func (r *Writer) WriteRegularLink(l org.RegularLink) {
167167
case "video":
168168
if l.Description == nil {
169169
imageSrc := getMediaURL(link)
170-
fmt.Fprintf(r, `<video src="%s" title="%s">%s</video>`, imageSrc, link, link)
170+
fmt.Fprintf(r, `<video src="%s">%s</video>`, imageSrc, link)
171171
} else {
172172
description := strings.TrimPrefix(org.String(l.Description...), "file:")
173173
videoSrc := getMediaURL([]byte(description))
174-
fmt.Fprintf(r, `<a href="%s"><video src="%s" title="%s"></video></a>`, link, videoSrc, videoSrc)
174+
fmt.Fprintf(r, `<a href="%s"><video src="%s">%s</video></a>`, link, videoSrc, videoSrc)
175175
}
176176
default:
177177
description := string(link)
178178
if l.Description != nil {
179179
description = r.WriteNodesAsString(l.Description...)
180180
}
181-
fmt.Fprintf(r, `<a href="%s" title="%s">%s</a>`, link, description, description)
181+
fmt.Fprintf(r, `<a href="%s">%s</a>`, link, description)
182182
}
183183
}
184184

modules/markup/orgmode/orgmode_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ func TestRender_StandardLinks(t *testing.T) {
3434
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
3535
}
3636

37-
googleRendered := "<p><a href=\"https://google.com/\" title=\"https://google.com/\">https://google.com/</a></p>"
38-
test("[[https://google.com/]]", googleRendered)
37+
test("[[https://google.com/]]",
38+
`<p><a href="https://google.com/">https://google.com/</a></p>`)
3939

4040
lnk := util.URLJoin(AppSubURL, "WikiPage")
4141
test("[[WikiPage][WikiPage]]",
42-
"<p><a href=\""+lnk+"\" title=\"WikiPage\">WikiPage</a></p>")
42+
`<p><a href="`+lnk+`">WikiPage</a></p>`)
4343
}
4444

4545
func TestRender_Media(t *testing.T) {
@@ -59,19 +59,23 @@ func TestRender_Media(t *testing.T) {
5959
result := util.URLJoin(AppSubURL, url)
6060

6161
test("[[file:"+url+"]]",
62-
"<p><img src=\""+result+"\" alt=\""+result+"\" title=\""+result+"\" /></p>")
62+
`<p><img src="`+result+`" alt="`+result+`" /></p>`)
6363

6464
// With description.
6565
test("[[https://example.com][https://example.com/example.svg]]",
6666
`<p><a href="https://example.com"><img src="https://example.com/example.svg" alt="https://example.com/example.svg" /></a></p>`)
67+
test("[[https://example.com][pre https://example.com/example.svg post]]",
68+
`<p><a href="https://example.com">pre <img src="https://example.com/example.svg" alt="https://example.com/example.svg" /> post</a></p>`)
6769
test("[[https://example.com][https://example.com/example.mp4]]",
68-
`<p><a href="https://example.com"><video src="https://example.com/example.mp4" title="https://example.com/example.mp4"></video></a></p>`)
70+
`<p><a href="https://example.com"><video src="https://example.com/example.mp4">https://example.com/example.mp4</video></a></p>`)
71+
test("[[https://example.com][pre https://example.com/example.mp4 post]]",
72+
`<p><a href="https://example.com">pre <video src="https://example.com/example.mp4">https://example.com/example.mp4</video> post</a></p>`)
6973

7074
// Without description.
7175
test("[[https://example.com/example.svg]]",
72-
`<p><img src="https://example.com/example.svg" alt="https://example.com/example.svg" title="https://example.com/example.svg" /></p>`)
76+
`<p><img src="https://example.com/example.svg" alt="https://example.com/example.svg" /></p>`)
7377
test("[[https://example.com/example.mp4]]",
74-
`<p><video src="https://example.com/example.mp4" title="https://example.com/example.mp4">https://example.com/example.mp4</video></p>`)
78+
`<p><video src="https://example.com/example.mp4">https://example.com/example.mp4</video></p>`)
7579
}
7680

7781
func TestRender_Source(t *testing.T) {

templates/user/auth/signin_inner.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<div class="gt-df gt-fc gt-jc">
6161
<div id="oauth2-login-navigator-inner" class="gt-df gt-fc gt-fw gt-ac gt-gap-3">
6262
{{range $provider := .OAuth2Providers}}
63-
<a class="{{$provider.Name}} ui button gt-df gt-ac gt-jc gt-py-3 oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$provider.Name}}">
63+
<a class="{{$provider.Name}} ui button gt-df gt-ac gt-jc gt-py-3 oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$provider.DisplayName}}">
6464
{{$provider.IconHTML 28}}
6565
{{ctx.Locale.Tr "sign_in_with_provider" $provider.DisplayName}}
6666
</a>

templates/user/auth/signup_inner.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<div class="gt-df gt-fc gt-jc">
6565
<div id="oauth2-login-navigator-inner" class="gt-df gt-fc gt-fw gt-ac gt-gap-3">
6666
{{range $provider := .OAuth2Providers}}
67-
<a class="{{$provider.Name}} ui button gt-df gt-ac gt-jc gt-py-3 oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$provider.Name}}">
67+
<a class="{{$provider.Name}} ui button gt-df gt-ac gt-jc gt-py-3 oauth-login-link" href="{{AppSubUrl}}/user/oauth2/{{$provider.DisplayName}}">
6868
{{$provider.IconHTML 28}}
6969
{{ctx.Locale.Tr "sign_in_with_provider" $provider.DisplayName}}
7070
</a>

web_src/js/features/common-global.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ export function initGlobalDropzone() {
247247
});
248248
}
249249
});
250+
this.on('error', function (file, message) {
251+
showErrorToast(message);
252+
this.removeFile(file);
253+
});
250254
},
251255
});
252256
}

0 commit comments

Comments
 (0)