Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public PropagationMode getPropagationMode() {
*/
public static Bind parse(String serialized) {
try {
// Split by ':' but not ':\' (Windows-style path)
String[] parts = serialized.split(":(?!\\\\)");
// Split by ':' but not the ':' that follows a Windows drive letter,
// whether written with a backslash (C:\host) or a forward slash (C:/host).
String[] parts = serialized.split(":(?!\\\\)(?<!^[A-Za-z]:)");
switch (parts.length) {
case 2: {
return new Bind(parts[0], new Volume(parts[1]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,39 @@ public void parseReadWriteWindows() {
assertThat(bind.getPropagationMode(), is(PropagationMode.DEFAULT_MODE));
}

@Test
public void parseUsingDefaultAccessModeForwardSlashWindows() {
Bind bind = Bind.parse("C:/host:/container");
assertThat(bind.getPath(), is("C:/host"));
assertThat(bind.getVolume().getPath(), is("/container"));
assertThat(bind.getAccessMode(), is(AccessMode.DEFAULT));
assertThat(bind.getSecMode(), is(SELContext.none));
assertThat(bind.getNoCopy(), nullValue());
assertThat(bind.getPropagationMode(), is(PropagationMode.DEFAULT_MODE));
}

@Test
public void parseReadWriteForwardSlashWindows() {
Bind bind = Bind.parse("C:/host:/container:rw");
assertThat(bind.getPath(), is("C:/host"));
assertThat(bind.getVolume().getPath(), is("/container"));
assertThat(bind.getAccessMode(), is(rw));
assertThat(bind.getSecMode(), is(SELContext.none));
assertThat(bind.getNoCopy(), nullValue());
assertThat(bind.getPropagationMode(), is(PropagationMode.DEFAULT_MODE));
}

@Test
public void parseReadOnlySELForwardSlashWindows() {
Bind bind = Bind.parse("c:/host:/container:ro,z");
assertThat(bind.getPath(), is("c:/host"));
assertThat(bind.getVolume().getPath(), is("/container"));
assertThat(bind.getAccessMode(), is(ro));
assertThat(bind.getSecMode(), is(SELContext.shared));
assertThat(bind.getNoCopy(), nullValue());
assertThat(bind.getPropagationMode(), is(PropagationMode.DEFAULT_MODE));
}

@Test
public void parseReadWriteNoCopyWindows() {
Bind bind = Bind.parse("C:\\host:/container:rw,nocopy");
Expand Down