From 6100d5f35728c4a023a28788434158754813f7e2 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 9 Dec 2024 22:51:20 +0900 Subject: [PATCH] fix plain-url-in-flow-mapping (#580) --- scanner/scanner.go | 4 ++++ yaml_test_suite_test.go | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scanner/scanner.go b/scanner/scanner.go index 8da8123..db711a6 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -940,6 +940,10 @@ func (s *Scanner) scanMapDelim(ctx *Context) (bool, error) { if s.startedFlowMapNum <= 0 && nc != ' ' && nc != '\t' && !s.isNewLineChar(nc) && !ctx.isNextEOS() { return false, nil } + if s.startedFlowMapNum > 0 && nc == '/' { + // like http:// + return false, nil + } if strings.HasPrefix(strings.TrimPrefix(string(ctx.obuf), " "), "\t") && !strings.HasPrefix(string(ctx.buf), "\t") { invalidTk := token.Invalid("tab character cannot use as a map key directly", string(ctx.obuf), s.pos()) diff --git a/yaml_test_suite_test.go b/yaml_test_suite_test.go index 187b39f..73cb459 100644 --- a/yaml_test_suite_test.go +++ b/yaml_test_suite_test.go @@ -51,7 +51,6 @@ var failureTestNames = []string{ "nested-implicit-complex-keys", // no json. "node-anchor-not-indented", // pass yamlv3. "plain-dashes-in-flow-sequence", - "plain-url-in-flow-mapping", // pass yamlv3. "question-mark-edge-cases/00", // no json. "question-mark-edge-cases/01", // no json. "scalar-value-with-two-anchors", // pass yamlv3.