X Tutup
Skip to content

Commit 8b9e7df

Browse files
committed
Fix parsing some issue template names
YAML parsing sometimes gets sabotaged by asterisks that follow the end of frontmatter (`---`). We now scope YAML parsing to only frontmatter and we don't pass any contents that follow.
1 parent 4ef468c commit 8b9e7df

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pkg/githubtemplate/github_template.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ mainLoop:
6666
// ExtractName returns the name of the template from YAML front-matter
6767
func ExtractName(filePath string) string {
6868
contents, err := ioutil.ReadFile(filePath)
69-
if err == nil && detectFrontmatter(contents)[0] == 0 {
69+
frontmatterBoundaries := detectFrontmatter(contents)
70+
if err == nil && frontmatterBoundaries[0] == 0 {
7071
templateData := struct {
7172
Name string
7273
}{}
73-
if err := yaml.Unmarshal(contents, &templateData); err == nil && templateData.Name != "" {
74+
if err := yaml.Unmarshal(contents[0:frontmatterBoundaries[1]], &templateData); err == nil && templateData.Name != "" {
7475
return templateData.Name
7576
}
7677
}

pkg/githubtemplate/github_template_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ name: Bug Report
148148
about: This is how you report bugs
149149
---
150150
151-
Template contents
152-
---
153-
More of template
151+
**Template contents**
154152
`,
155153
args: args{
156154
filePath: tmpfile.Name(),

0 commit comments

Comments
 (0)
X Tutup