diff --git a/pkg/parser/frontmatter_content.go b/pkg/parser/frontmatter_content.go index e736ac1b83f..203ad073c65 100644 --- a/pkg/parser/frontmatter_content.go +++ b/pkg/parser/frontmatter_content.go @@ -55,6 +55,9 @@ func ExtractFrontmatterFromContent(content string) (*FrontmatterResult, error) { frontmatterLines := lines[1:endIndex] frontmatterYAML := strings.Join(frontmatterLines, "\n") + // Sanitize no-break whitespace characters (U+00A0) which break the YAML parser + frontmatterYAML = strings.ReplaceAll(frontmatterYAML, "\u00A0", " ") + // Parse YAML var frontmatter map[string]any if err := yaml.Unmarshal([]byte(frontmatterYAML), &frontmatter); err != nil { diff --git a/pkg/parser/frontmatter_extraction_test.go b/pkg/parser/frontmatter_extraction_test.go index 10a9b69e3a2..77e342e510d 100644 --- a/pkg/parser/frontmatter_extraction_test.go +++ b/pkg/parser/frontmatter_extraction_test.go @@ -55,6 +55,15 @@ This is a test workflow with empty frontmatter.`, content: "---\ntitle: Test\nno closing delimiter", wantErr: true, }, + { + name: "no-break whitespace in values", + content: "---\ntitle:\u00A0Test\u00A0Workflow\nengine:\u00A0copilot\n---\n\n# Content", + wantYAML: map[string]any{ + "title": "Test Workflow", + "engine": "copilot", + }, + wantMarkdown: "# Content", + }, } for _, tt := range tests {