Browse code

fix whitespace that precedes the escape in a multiline string.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)

Erik Hollensbe authored on 2014/06/25 15:54:53
Showing 2 changed files
... ...
@@ -1490,3 +1490,27 @@ func TestBuildAddToSymlinkDest(t *testing.T) {
1490 1490
 	}
1491 1491
 	logDone("build - add to symlink destination")
1492 1492
 }
1493
+
1494
+func TestBuildEscapeWhitespace(t *testing.T) {
1495
+	name := "testbuildescaping"
1496
+	defer deleteImages(name)
1497
+
1498
+	_, err := buildImage(name, `
1499
+  FROM busybox
1500
+  MAINTAINER "Docker \
1501
+IO <io@\
1502
+docker.com>"
1503
+  `, true)
1504
+
1505
+	res, err := inspectField(name, "Author")
1506
+
1507
+	if err != nil {
1508
+		t.Fatal(err)
1509
+	}
1510
+
1511
+	if res != "Docker IO <io@docker.com>" {
1512
+		t.Fatal("Parsed string did not match the escaped string")
1513
+	}
1514
+
1515
+	logDone("build - validate escaping whitespace")
1516
+}
... ...
@@ -761,7 +761,7 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error {
761 761
 }
762 762
 
763 763
 // Long lines can be split with a backslash
764
-var lineContinuation = regexp.MustCompile(`\s*\\\s*\n`)
764
+var lineContinuation = regexp.MustCompile(`\\\s*\n`)
765 765
 
766 766
 func (b *buildFile) Build(context io.Reader) (string, error) {
767 767
 	tmpdirPath, err := ioutil.TempDir("", "docker-build")