While look at #27039 I noticed that we allow for whitespace after
the continuation char (\\) which is wrong. It needs to be the very
last char in the line.
Signed-off-by: Doug Davis <dug@us.ibm.com>
| ... | ... |
@@ -61,7 +61,7 @@ func SetEscapeToken(s string, d *Directive) error {
|
| 61 | 61 |
return fmt.Errorf("invalid ESCAPE '%s'. Must be ` or \\", s)
|
| 62 | 62 |
} |
| 63 | 63 |
d.EscapeToken = rune(s[0]) |
| 64 |
- d.LineContinuationRegex = regexp.MustCompile(`\` + s + `[ \t]*$`) |
|
| 64 |
+ d.LineContinuationRegex = regexp.MustCompile(`\` + s + `$`) |
|
| 65 | 65 |
return nil |
| 66 | 66 |
} |
| 67 | 67 |
|
| ... | ... |
@@ -6901,6 +6901,17 @@ func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
|
| 6901 | 6901 |
} |
| 6902 | 6902 |
} |
| 6903 | 6903 |
|
| 6904 |
+func (s *DockerSuite) TestContinueCharSpace(c *check.C) {
|
|
| 6905 |
+ // Test to make sure that we don't treat a \ as a continuation |
|
| 6906 |
+ // character IF there are spaces (or tabs) after it on the same line |
|
| 6907 |
+ name := "testbuildcont" |
|
| 6908 |
+ _, err := buildImage(name, "FROM busybox\nRUN echo hi \\\t\nbye", true) |
|
| 6909 |
+ c.Assert(err, check.NotNil, check.Commentf("Build 1 should fail - didn't"))
|
|
| 6910 |
+ |
|
| 6911 |
+ _, err = buildImage(name, "FROM busybox\nRUN echo hi \\ \nbye", true) |
|
| 6912 |
+ c.Assert(err, check.NotNil, check.Commentf("Build 2 should fail - didn't"))
|
|
| 6913 |
+} |
|
| 6914 |
+ |
|
| 6904 | 6915 |
// Test case for #24912. |
| 6905 | 6916 |
func (s *DockerSuite) TestBuildStepsWithProgress(c *check.C) {
|
| 6906 | 6917 |
name := "testbuildstepswithprogress" |