Tcl Library Source Code

View Ticket
Login
Ticket UUID: 815408482c2f06a80e2d0a79185a3dced3b33e28
Title: yaml::yaml2dict misidentifies * as alias indicator on plain scalar continuation lines
Type: Bug Version: 8.6
Submitter: anonymous Created on: 2026-04-12 01:39:52
Subsystem: yaml Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-04-12 01:39:52
Resolution: None Closed By: nobody
    Closed on:
Description:
When a plain (unquoted) scalar spans multiple lines and a continuation
line begins with `*` (after indentation whitespace), yaml2dict treats
the `*` as a YAML alias indicator rather than literal text. This
violates YAML spec §7.3.3, which restricts alias indicators to
positions where a node is expected — not inside an already-open plain
scalar.

Minimal reproduction:

    package require yaml
    ::yaml::yaml2dict {
    items:
    - key: some long text
        *bold text*
      other: val
    }

Result:

    line(5): Could not find the anchor-name(current-version,
    "after refering" is not supported)

Expected: parse succeeds; key = "some long text *bold text*"

The same `*` is correctly treated as literal text when it appears:
- mid-line in a plain scalar (e.g.  key: text ending *bold*)
- inside a block scalar (| or >)
- inside a quoted string (' or ")

The bug is in the _parseValue / _parseBlockLine dispatch (yaml.tcl
around line 405): upon reading a new line within a plain scalar, the
parser re-enters the top-level character switch and matches `*` as an
alias node, instead of continuing to accumulate the plain scalar value.

Python's PyYAML and Go's go-yaml parse the same input correctly.

tcllib version: 2.0 (as shipped with Debian/Ubuntu tcllib package)
Tcl version: 8.6