Skip to content

Commit

Permalink
scanner: scanHeredoc(): Accept any number of CRs (\r) at end of line.
Browse files Browse the repository at this point in the history
When there are multiple cartridge returns at the end of the line, the regular expression will consider n-1 of them to be part of the string. Later, the last `\r` is removed. That may mean that a line that did previously *not* terminate a heredoc string may now terminate it, changing the meaning of the HCL file.
  • Loading branch information
octo committed Apr 3, 2018
1 parent 6a21c5a commit 25340db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hcl/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ func (s *Scanner) scanHeredoc() {

var identRegexp *regexp.Regexp
if identBytes[0] == '-' {
identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\z`, identBytes[1:]))
identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\r*\z`, identBytes[1:]))
} else {
identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\z`, identBytes))
identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\r*\z`, identBytes))
}

// Read the actual string value
Expand Down

0 comments on commit 25340db

Please sign in to comment.