Skip to content

Commit 64973cf

Browse files
zeripathlunnylafriks
authored
Use path not filepath in template filenames (#21993)
Paths in git are always separated by `/` not `\` - therefore we should `path` and not `filepath` Fix #21987 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent f0bd219 commit 64973cf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: modules/issue/template/unmarshal.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package template
66
import (
77
"fmt"
88
"io"
9-
"path/filepath"
9+
"path"
1010
"strconv"
1111

1212
"code.gitea.io/gitea/modules/git"
@@ -43,7 +43,7 @@ func Unmarshal(filename string, content []byte) (*api.IssueTemplate, error) {
4343

4444
// UnmarshalFromEntry parses out a valid template from the blob in entry
4545
func UnmarshalFromEntry(entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) {
46-
return unmarshalFromEntry(entry, filepath.Join(dir, entry.Name()))
46+
return unmarshalFromEntry(entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here
4747
}
4848

4949
// UnmarshalFromCommit parses out a valid template from the commit
@@ -108,7 +108,7 @@ func unmarshal(filename string, content []byte) (*api.IssueTemplate, error) {
108108
// It could be a valid markdown with two horizontal lines, or an invalid markdown with wrong metadata.
109109

110110
it.Content = string(content)
111-
it.Name = filepath.Base(it.FileName)
111+
it.Name = path.Base(it.FileName) // paths in Git are always '/' separated - do not use filepath!
112112
it.About, _ = util.SplitStringAtByteN(it.Content, 80)
113113
} else {
114114
it.Content = templateBody

0 commit comments

Comments
 (0)