Prechádzať zdrojové kódy

Merge pull request #30010 from thaJeztah/master-revert-27146

Revert "Require continuation char to be last char in a line"
Brian Goff 8 rokov pred
rodič
commit
bf71db7a12

+ 1 - 1
builder/dockerfile/parser/parser.go

@@ -61,7 +61,7 @@ func SetEscapeToken(s string, d *Directive) error {
 		return fmt.Errorf("invalid ESCAPE '%s'. Must be ` or \\", s)
 		return fmt.Errorf("invalid ESCAPE '%s'. Must be ` or \\", s)
 	}
 	}
 	d.EscapeToken = rune(s[0])
 	d.EscapeToken = rune(s[0])
-	d.LineContinuationRegex = regexp.MustCompile(`\` + s + `$`)
+	d.LineContinuationRegex = regexp.MustCompile(`\` + s + `[ \t]*$`)
 	return nil
 	return nil
 }
 }
 
 

+ 2 - 0
builder/dockerfile/parser/testfiles/continueIndent/Dockerfile

@@ -13,6 +13,8 @@ world
 RUN echo hello \
 RUN echo hello \
 goodbye\
 goodbye\
 frog
 frog
+RUN echo hello  \  
+world
 RUN echo hi \
 RUN echo hi \
  \
  \
  world \
  world \

+ 1 - 0
builder/dockerfile/parser/testfiles/continueIndent/result

@@ -3,6 +3,7 @@
 (run "echo hello    world")
 (run "echo hello    world")
 (run "echo hello  world")
 (run "echo hello  world")
 (run "echo hello goodbyefrog")
 (run "echo hello goodbyefrog")
+(run "echo hello  world")
 (run "echo hi   world  goodnight")
 (run "echo hi   world  goodnight")
 (run "echo goodbyefrog")
 (run "echo goodbyefrog")
 (run "echo goodbyefrog")
 (run "echo goodbyefrog")

+ 0 - 11
integration-cli/docker_cli_build_test.go

@@ -7037,17 +7037,6 @@ func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
 	}
 	}
 }
 }
 
 
-func (s *DockerSuite) TestContinueCharSpace(c *check.C) {
-	// Test to make sure that we don't treat a \ as a continuation
-	// character IF there are spaces (or tabs) after it on the same line
-	name := "testbuildcont"
-	_, err := buildImage(name, "FROM busybox\nRUN echo hi \\\t\nbye", true)
-	c.Assert(err, check.NotNil, check.Commentf("Build 1 should fail - didn't"))
-
-	_, err = buildImage(name, "FROM busybox\nRUN echo hi \\ \nbye", true)
-	c.Assert(err, check.NotNil, check.Commentf("Build 2 should fail - didn't"))
-}
-
 // Test case for #24912.
 // Test case for #24912.
 func (s *DockerSuite) TestBuildStepsWithProgress(c *check.C) {
 func (s *DockerSuite) TestBuildStepsWithProgress(c *check.C) {
 	name := "testbuildstepswithprogress"
 	name := "testbuildstepswithprogress"