Skip to content

Commit 993257e

Browse files
authored
Merge branch 'main' into branch-by-id
2 parents b2da0c5 + 513951b commit 993257e

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ Janis Estelmann <[email protected]> (@KN4CK3R)
4545
Steven Kriegler <[email protected]> (@justusbunsi)
4646
Jimmy Praet <[email protected]> (@jpraet)
4747
Leon Hofmeister <[email protected]> (@delvh)
48+
Gusted <[email protected]) (@Gusted)

custom/conf/app.example.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ PATH =
14001400
;; Built-in: loopback (for localhost), private (for LAN/intranet), external (for public hosts on internet), * (for all hosts)
14011401
;; CIDR list: 1.2.3.0/8, 2001:db8::/32
14021402
;; Wildcard hosts: *.mydomain.com, 192.168.100.*
1403+
;; Since 1.15.7. Default to * for 1.15.x, external for 1.16 and later
14031404
;ALLOWED_HOST_LIST = external
14041405
;;
14051406
;; Allow insecure certification

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ Define allowed algorithms and their minimum key length (use -1 to disable a type
581581

582582
- `QUEUE_LENGTH`: **1000**: Hook task queue length. Use caution when editing this value.
583583
- `DELIVER_TIMEOUT`: **5**: Delivery timeout (sec) for shooting webhooks.
584-
- `ALLOWED_HOST_LIST`: **external**: Webhook can only call allowed hosts for security reasons. Comma separated list.
584+
- `ALLOWED_HOST_LIST`: **external**: Since 1.15.7. Default to `*` for 1.15.x, `external` for 1.16 and later. Webhook can only call allowed hosts for security reasons. Comma separated list.
585585
- Built-in networks:
586586
- `loopback`: 127.0.0.0/8 for IPv4 and ::1/128 for IPv6, localhost is included.
587587
- `private`: RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and RFC 4193 (FC00::/7). Also called LAN/Intranet.

services/gitdiff/gitdiff.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,12 @@ parsingLoop:
839839
case strings.HasPrefix(line, "--- "):
840840
// Handle ambiguous filenames
841841
if curFile.IsAmbiguous {
842-
if len(line) > 6 && line[4] == 'a' {
842+
// The shortest string that can end up here is:
843+
// "--- a\t\n" without the qoutes.
844+
// This line has a len() of 7 but doesn't contain a oldName.
845+
// So the amount that the line need is at least 8 or more.
846+
// The code will otherwise panic for a out-of-bounds.
847+
if len(line) > 7 && line[4] == 'a' {
843848
curFile.OldName = line[6 : len(line)-1]
844849
if line[len(line)-2] == '\t' {
845850
curFile.OldName = curFile.OldName[:len(curFile.OldName)-1]
@@ -1194,6 +1199,11 @@ func readFileName(rd *strings.Reader) (string, bool) {
11941199
_ = rd.UnreadByte()
11951200
if char == '"' {
11961201
fmt.Fscanf(rd, "%q ", &name)
1202+
if len(name) == 0 {
1203+
log.Error("Reader has no file name: %v", rd)
1204+
return "", true
1205+
}
1206+
11971207
if name[0] == '\\' {
11981208
name = name[1:]
11991209
}

services/gitdiff/gitdiff_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,22 @@ func TestDiffToHTML_14231(t *testing.T) {
541541

542542
assertEqual(t, expected, output)
543543
}
544+
545+
func TestNoCrashes(t *testing.T) {
546+
type testcase struct {
547+
gitdiff string
548+
}
549+
550+
tests := []testcase{
551+
{
552+
gitdiff: "diff --git \n--- a\t\n",
553+
},
554+
{
555+
gitdiff: "diff --git \"0\n",
556+
},
557+
}
558+
for _, testcase := range tests {
559+
// It shouldn't crash, so don't care about the output.
560+
ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(testcase.gitdiff))
561+
}
562+
}

web_src/js/features/comp/ImagePaste.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {appSubUrl, csrfToken} = window.config;
1+
const {csrfToken} = window.config;
22

33
async function uploadFile(file, uploadUrl) {
44
const formData = new FormData();
@@ -67,7 +67,7 @@ export function initCompImagePaste($target) {
6767
const name = img.name.substr(0, img.name.lastIndexOf('.'));
6868
insertAtCursor(textarea, `![${name}]()`);
6969
const data = await uploadFile(img, uploadUrl);
70-
replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](${appSubUrl}/attachments/${data.uuid})`);
70+
replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](/attachments/${data.uuid})`);
7171
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid);
7272
dropzoneFiles.appendChild(input[0]);
7373
}
@@ -83,7 +83,7 @@ export function initSimpleMDEImagePaste(simplemde, dropzone, files) {
8383
const name = img.name.substr(0, img.name.lastIndexOf('.'));
8484
const data = await uploadFile(img, uploadUrl);
8585
const pos = simplemde.codemirror.getCursor();
86-
simplemde.codemirror.replaceRange(`![${name}](${appSubUrl}/attachments/${data.uuid})`, pos);
86+
simplemde.codemirror.replaceRange(`![${name}](/attachments/${data.uuid})`, pos);
8787
const input = $(`<input id="${data.uuid}" name="files" type="hidden">`).val(data.uuid);
8888
files.append(input);
8989
}

0 commit comments

Comments
 (0)