Skip to content

Split mount directives on the first equals sign#2016

Open
devops-thiago wants to merge 1 commit into
apple:mainfrom
devops-thiago:fix-mount-directive-equals
Open

Split mount directives on the first equals sign#2016
devops-thiago wants to merge 1 commit into
apple:mainfrom
devops-thiago:fix-mount-directive-equals

Conversation

@devops-thiago

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Fixes #2012.

Parser.mount splits each comma-separated directive with maxSplits: 2. In Swift that parameter counts splits rather than resulting elements, so a value that itself contains an equals sign produces three components:

"src=/tmp/a=b".split(separator: "=", maxSplits: 2)
// ["src", "/tmp/a", "b"]

The parser then requires exactly two components and throws invalid directive format missing value. Equals signs are legal in POSIX path names, so a bind mount whose source or destination contains one cannot be used today.

Splitting on the first equals sign keeps the remainder as the value. Directives that carry no value, such as readonly, still produce a single component and are unaffected.

#1978 and #1999 fix the same defect in Parser.labels. Neither changes Parser.mount.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

testMountBindSourceContainingEquals creates a directory whose name contains an equals sign and mounts it by absolute path. Against the current code the test fails with invalid directive format missing value; with this change it passes. The existing mount and publish-port tests continue to pass.

Parser.mount split each comma-separated directive with maxSplits: 2, which
yields three components when the value itself contains an equals sign. The
parser then requires exactly two components, so any mount whose source or
destination path contains "=" failed with "invalid directive format missing
value". Equals signs are legal in POSIX path names.

Splitting on the first equals sign keeps the remainder as the value.

Fixes apple#2012
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.

[Bug]: --mount rejects a directive whose value contains "="

1 participant