mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
core: Add tests to Replacer; fix panic (fixes #2852)
This commit is contained in:
parent
93bc1b72e3
commit
ad90b273db
2 changed files with 67 additions and 10 deletions
|
@ -116,11 +116,14 @@ func (r *replacer) replace(input, empty string,
|
|||
continue
|
||||
}
|
||||
|
||||
// write the substring from the last cursor to this point
|
||||
sb.WriteString(input[lastWriteCursor:i])
|
||||
|
||||
// find the end of the placeholder
|
||||
end := strings.Index(input[i:], string(phClose)) + i
|
||||
if end < i {
|
||||
continue
|
||||
}
|
||||
|
||||
// write the substring from the last cursor to this point
|
||||
sb.WriteString(input[lastWriteCursor:i])
|
||||
|
||||
// trim opening bracket
|
||||
key := input[i+1 : end]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue