mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 14:13:48 +03:00
caddyfile: Assert having a space after heredoc marker to simply check (#6117)
This commit is contained in:
parent
4284e39a17
commit
8bbf8ec629
1 changed files with 8 additions and 4 deletions
|
@ -124,19 +124,23 @@ func Format(input []byte) []byte {
|
||||||
}
|
}
|
||||||
// if we're in a heredoc, all characters are read&write as-is
|
// if we're in a heredoc, all characters are read&write as-is
|
||||||
if heredoc == heredocOpened {
|
if heredoc == heredocOpened {
|
||||||
write(ch)
|
|
||||||
heredocClosingMarker = append(heredocClosingMarker, ch)
|
heredocClosingMarker = append(heredocClosingMarker, ch)
|
||||||
if len(heredocClosingMarker) > len(heredocMarker) {
|
if len(heredocClosingMarker) > len(heredocMarker)+1 { // We assert that the heredocClosingMarker is followed by a unicode.Space
|
||||||
heredocClosingMarker = heredocClosingMarker[1:]
|
heredocClosingMarker = heredocClosingMarker[1:]
|
||||||
}
|
}
|
||||||
// check if we're done
|
// check if we're done
|
||||||
if slices.Equal(heredocClosingMarker, heredocMarker) {
|
if unicode.IsSpace(ch) && slices.Equal(heredocClosingMarker[:len(heredocClosingMarker)-1], heredocMarker) {
|
||||||
heredocMarker = nil
|
heredocMarker = nil
|
||||||
heredocClosingMarker = nil
|
heredocClosingMarker = nil
|
||||||
heredoc = heredocClosed
|
heredoc = heredocClosed
|
||||||
|
} else {
|
||||||
|
write(ch)
|
||||||
|
if ch == '\n' {
|
||||||
|
heredocClosingMarker = heredocClosingMarker[:0]
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if last == '<' && space {
|
if last == '<' && space {
|
||||||
space = false
|
space = false
|
||||||
|
|
Loading…
Reference in a new issue