Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
f46da403
Commit
f46da403
authored
Oct 30, 2018
by
Billie Cleek
Committed by
Matt Holt
Oct 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddyfile: fix env var expansion after Go template (#2304)
parent
1f8d1df4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
caddyfile/parse.go
caddyfile/parse.go
+6
-1
caddyfile/parse_test.go
caddyfile/parse_test.go
+7
-0
No files found.
caddyfile/parse.go
View file @
f46da403
...
...
@@ -424,7 +424,12 @@ func replaceEnvVars(s string) string {
func
replaceEnvReferences
(
s
,
refStart
,
refEnd
string
)
string
{
index
:=
strings
.
Index
(
s
,
refStart
)
for
index
!=
-
1
{
endIndex
:=
strings
.
Index
(
s
,
refEnd
)
endIndex
:=
strings
.
Index
(
s
[
index
:
],
refEnd
)
if
endIndex
==
-
1
{
break
}
endIndex
+=
index
if
endIndex
>
index
+
len
(
refStart
)
{
ref
:=
s
[
index
:
endIndex
+
len
(
refEnd
)]
s
=
strings
.
Replace
(
s
,
ref
,
os
.
Getenv
(
ref
[
len
(
refStart
)
:
len
(
ref
)
-
len
(
refEnd
)]),
-
1
)
...
...
caddyfile/parse_test.go
View file @
f46da403
...
...
@@ -526,6 +526,13 @@ func TestEnvironmentReplacement(t *testing.T) {
if
actual
,
expected
:=
blocks
[
0
]
.
Tokens
[
"dir1"
][
1
]
.
Text
,
"Test foobar test"
;
expected
!=
actual
{
t
.
Errorf
(
"Expected argument to be '%s' but was '%s'"
,
expected
,
actual
)
}
// after end token
p
=
testParser
(
":1234
\n
answer
\"
{{ .Name }} {$FOOBAR}
\"
"
)
blocks
,
_
=
p
.
parseAll
()
if
actual
,
expected
:=
blocks
[
0
]
.
Tokens
[
"answer"
][
1
]
.
Text
,
"{{ .Name }} foobar"
;
expected
!=
actual
{
t
.
Errorf
(
"Expected argument to be '%s' but was '%s'"
,
expected
,
actual
)
}
}
func
testParser
(
input
string
)
parser
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment