moby / moby/buildkit

single quote escaping and json

Open
#4,253 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

impact/dockerfile
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

The following Dockerfile fails to build:

FROM alpine
VOLUME ["/foo'bar"]
RUN ls

Result:

Step 1/3 : FROM alpine
 ---> 3fd9065eaf02
Step 2/3 : VOLUME ["/foo'bar"]
failed to process "/foo'bar": unexpected end of statement while looking for matching single-quote

This one works, but should produce a different result (i.e. it should create the directory foo\'bar instead of foo'bar):

FROM alpine
VOLUME ["/foo\\'bar"]
RUN ls

Result:

Step 1/3 : FROM alpine
 ---> 3fd9065eaf02
Step 2/3 : VOLUME ["/foo\\'bar"]
 ---> Running in 7067c0882c91
Removing intermediate container 7067c0882c91
 ---> ec5fda9a6b67
Step 3/3 : RUN ls
 ---> Running in 14ded6878716
bin
dev
etc
foo'bar
home
lib
media
mnt
proc
root
run
sbin
srv
sys
tmp
usr
var

Most probably the parser looks for single quotes before decoding the JSON array. The COPY and ADD instructions are affected too.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Dockerfile examples with JSON-array forms of VOLUME, then trace how the parser handles the affected VOLUME, COPY, and ADD instructions. Done means literal apostrophes build successfully, escaped apostrophes retain their distinct result, and regression coverage verifies both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, dockerfile, go
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.