Skip to content

Commit c247bd0

Browse files
authored
Merge pull request #245 from octo/cartridge-return
scanner: Improve regular expression in "scanner".scanHeredoc().
2 parents f40e974 + 25340db commit c247bd0

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

hcl/printer/printer_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ func TestFormatValidOutput(t *testing.T) {
153153
cases := []string{
154154
"#\x00",
155155
"#\ue123t",
156+
"Y=<<4\n4/\n\n\n/4/@=4/\n\n\n/4000000004\r\r\n00004\n",
157+
"x=<<_\n_\r\r\n_\n",
156158
}
157159

158160
for _, c := range cases {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
obj {
22
foo = [<<EOF
33
TEXT!
4+
!!EOF
45
EOF
56
]
67
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
obj {
22
foo = [<<EOF
33
TEXT!
4+
!!EOF
45
EOF
56
]
67
}

hcl/scanner/scanner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ func (s *Scanner) scanHeredoc() {
440440

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

448448
// Read the actual string value

0 commit comments

Comments
 (0)