Skip to content

parser: fix parsing broken strings in exec format#80

Merged
lorenzo merged 1 commit intohadolint:masterfrom
m-ildefons:exec-format-broken-long-string
Mar 7, 2022
Merged

parser: fix parsing broken strings in exec format#80
lorenzo merged 1 commit intohadolint:masterfrom
m-ildefons:exec-format-broken-long-string

Conversation

@m-ildefons
Copy link
Copy Markdown
Member

  • Fix parsing of long strings broken into multiple lines in the
    exec/JSON format of CMD, RUN and ENTRYPOINT statements
  • Remove legacy alias stringLiteral from
    Language.Docker.Parser.Prelude

When specifying a command with arguments in JSON notation (aka. exec
format), sometimes it is useful to break a longer string into several
lines. Although this is not legal JSON syntax, it is supported by Docker
and results are as expected. Therefore the parser should not fail on
these occasions, but rather produce the expected result. In addition to
that the parser needs to remove escaped newlines from the resulting
string.

The legacy alias stringLiteral from the Language.Docker.Parser.Prelude
module has been removed, because now there is a difference between
parsing a double quoted string literal as-is or doing so and removing
escaped newlines from the resulting string.

The test suite has been reorganized by moving the tests relating to the
CMD statement into their own submodule.

fixes: hadolint/hadolint#783

- Fix parsing of long strings broken into multiple lines in the
  exec/JSON format of CMD, RUN and ENTRYPOINT statements
- Remove legacy alias `stringLiteral` from
  Language.Docker.Parser.Prelude

When specifying a command with arguments in JSON notation (aka. exec
format), sometimes it is useful to break a longer string into several
lines. Although this is not legal JSON syntax, it is supported by Docker
and results are as expected. Therefore the parser should not fail on
these occasions, but rather produce the expected result. In addition to
that the parser needs to remove escaped newlines from the resulting
string.

The legacy alias `stringLiteral` from the Language.Docker.Parser.Prelude
module has been removed, because now there is a difference between
parsing a double quoted string literal as-is or doing so and removing
escaped newlines from the resulting string.

The test suite has been reorganized by moving the tests relating to the
`CMD` statement into their own submodule.

fixes: hadolint/hadolint#783
@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Mar 7, 2022

looks great!

@lorenzo lorenzo merged commit b1f303d into hadolint:master Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DL3025] False positive with multiline instruction

2 participants