aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorAziz Rmadi <[email protected]>2024-06-19 08:27:10 -0500
committerGitHub <[email protected]>2024-06-19 13:27:10 +0000
commitc2ccf8690f315aa0ebab930c3aadcc6cd11fc9e9 (patch)
tree2c44982f86dc5de6f8ba5927d2b792419a439415 /modules
parent99dcdf7e426f0dcbdffe510f241ae8a4fd5a56e6 (diff)
downloadcaddy-c2ccf8690f315aa0ebab930c3aadcc6cd11fc9e9.tar.gz
caddy-c2ccf8690f315aa0ebab930c3aadcc6cd11fc9e9.zip
fileserver: Remove newline characters from precomputed etags (#6394)
* Removed newline characters from precomputed etags * Update modules/caddyhttp/fileserver/staticfiles.go --------- Co-authored-by: Matt Holt <[email protected]>
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index 5d54742dd..3d7032804 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -15,6 +15,7 @@
package fileserver
import (
+ "bytes"
"errors"
"fmt"
"io"
@@ -690,6 +691,10 @@ func (fsrv *FileServer) getEtagFromFile(fileSystem fs.FS, filename string) (stri
if err != nil {
return "", fmt.Errorf("cannot read etag from file %s: %v", etagFilename, err)
}
+
+ // Etags should not contain newline characters
+ etag = bytes.ReplaceAll(etag, []byte("\n"), []byte{})
+
return string(etag), nil
}
return "", nil