From 71cccaf4c9fbef5e173a2b930d2c5656e73e508d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 3 Sep 2026 20:43:04 +0200 Subject: [PATCH] Reject a leading quote that opens no JSON, and give the inline walk one home --- cmd/fejkdata/main.go | 2 +- inline.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/fejkdata/main.go b/cmd/fejkdata/main.go index b2bcd3d..8a077a8 100644 --- a/cmd/fejkdata/main.go +++ b/cmd/fejkdata/main.go @@ -279,7 +279,7 @@ func classify(arg string) (argKind, error) { if strings.ContainsRune(arg, '{') || (isJSONStart(arg) && json.Valid([]byte(arg))) { return argTemplate, nil } - if i := strings.IndexAny(arg, "[]"); i >= 0 { + if i := strings.IndexAny(arg, `[]"`); i >= 0 { return argPath, fmt.Errorf("%q holds a %q, which no path may, and it is not valid JSON, so it names no template either", arg, arg[i:i+1]) } return argPath, nil diff --git a/inline.go b/inline.go index cc0a9ab..eca8e6a 100644 --- a/inline.go +++ b/inline.go @@ -36,10 +36,11 @@ func (f *Generator) NewTemplate(input string) (*Template, error) { if err != nil { return nil, fmt.Errorf("fejkdata: %w", err) } - if err := linkNodeRefs(n, f.categories); err != nil { + scope := inlineScope(n) + if err := linkNodeRefs(scope, f.categories); err != nil { return nil, fmt.Errorf("fejkdata: %w", err) } - if err := checkScope(inlineScope(n)); err != nil { + if err := checkScope(scope); err != nil { return nil, fmt.Errorf("fejkdata: %w", err) } return &Template{g: f, n: n}, nil @@ -77,8 +78,8 @@ func compileInput(input string) (node, error) { // linkNodeRefs binds the references in an inline node's templates against the // loaded tree. An inline template sits in no folder, so . and .. name nothing and // are rejected for the root spelling they would otherwise silently mean. -func linkNodeRefs(n node, root map[string]node) error { - return eachNode(n, "template", func(path string, m node) error { +func linkNodeRefs(scope nodeScope, root map[string]node) error { + return scope(func(path string, m node) error { t, ok := m.(*template) if !ok { return nil