Skip to content

Sequence with embedded colon confuses parser #17

@stevedonovan

Description

@stevedonovan

I noticed this when parsing docker-compose.yml files, which have things like this:

    ports:
      - 172.17.0.1:19000:19000

Where the item is to be considered a string. Generally a colon without a following space is ignored in these situations.

We go wrong at line 513 in parseseq:

    if sfind(rest, '^[^\'\"%s]*:') then
      -- Inline nested hash
      local indent2 = j
      lines[1] = string.rep(' ', indent2)..rest
      tinsert(seq, parsemap('', lines, indent2))

The minimal fix is simple - insist that there is a space after the colon:

    if sfind(rest, '^[^\'\"%s]*:%s') then

I couldn't find any tests for 'inline nested hash' so I don't know if it continues to do that job.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions