Reto
(Reto Brunner)
August 5, 2024, 5:53am
1
1. The problem I’m having:
If I understood the placeholder docs, I’m supposed to be able to escape them if I do want the literal value of {file}
by using \{file\}
Now, this works when executed like that:
# Caddyfile
http://localhost:8080 {
respond "\{file\}" 200
}
Meaning if I curl it with say curl localhost:8080/asdf/testytest
this ends up as “{file}”
However, when I use the “sites enabled” type of folder structure and import the file, the quoting seems to be stripped.
#Caddyfile
import ./*.conf
# ./whatever.conf
http://localhost:8080 {
respond "\{file\}" 200
}
Now the same curl ends up as “testytest”.
This seems strange to me, why is the quoting stripped?
I could understand it in a snippet but this imports the whole file, why is a level of quoting stripped?
3. Caddy version:
v2.8.4
4. How I installed and ran Caddy:
distro package and manually on the cli, don’t think it matters
a. System environment:
Arch Linux
b. Command:
caddy
Hmm, yeah I can confirm that bug. It has to do with the Caddyfile shorthand replacement Caddyfile Concepts — Caddy Documentation I think.
I can replicate it with something as simple as this:
(foo) {
respond "\{file\}" 200
}
:8881 {
import foo
respond "\{file\}" 200
}
Adapting with caddy adapt -p
produces this:
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":8881"
],
"routes": [
{
"handle": [
{
"body": "{http.request.uri.path.file}",
"handler": "static_response",
"status_code": 200
},
{
"body": "\\{file\\}",
"handler": "static_response",
"status_code": 200
}
]
}
]
}
}
}
}
}
As you can see, the first one (imported snippet) gets transformed even though it was meant to be escaped, but the second one doesn’t. Strange.
I don’t have to dig into this further right now, but if you’d like to file an issue on Github, that would help to remind us to fix it.
1 Like
system
(system)
Closed
September 7, 2024, 3:58am
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.