mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-29 23:25:50 +08:00
Fix for Issue 72: Markdown: 500 for YAML metadata
This commit is contained in:
@ -154,6 +154,19 @@ func (y *YAMLMetadataParser) Parse(b []byte) ([]byte, error) {
|
||||
if err := yaml.Unmarshal(b, &m); err != nil {
|
||||
return markdown, err
|
||||
}
|
||||
|
||||
// convert variables (if present) to map[string]interface{}
|
||||
// to match expected type
|
||||
if vars, ok := m["variables"].(map[interface{}]interface{}); ok {
|
||||
vars1 := make(map[string]interface{})
|
||||
for k, v := range vars {
|
||||
if key, ok := k.(string); ok {
|
||||
vars1[key] = v
|
||||
}
|
||||
}
|
||||
m["variables"] = vars1
|
||||
}
|
||||
|
||||
y.metadata.load(m)
|
||||
return markdown, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user