@marcel91200 / caddy Mirror · read-only / commits / c2ccf869
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 12, 10:45 UTC

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 <mholt@users.noreply.github.com>

Aziz Rmadi committed Jun 19, 2024 at 08:27 UTC c2ccf8690f315aa0ebab930c3aadcc6cd11fc9e9
1 file changed +5
modules/caddyhttp/fileserver/staticfiles.go
+5
@@ -15,6 +15,7 @@
15 package fileserver
16
17 import (
18 + "bytes"
19 "errors"
20 "fmt"
21 "io"
@@ -690,6 +691,10 @@ func (fsrv *FileServer) getEtagFromFile(fileSystem fs.FS, filename string) (stri
691 if err != nil {
692 return "", fmt.Errorf("cannot read etag from file %s: %v", etagFilename, err)
693 }
694 +
695 + // Etags should not contain newline characters
696 + etag = bytes.ReplaceAll(etag, []byte("\n"), []byte{})
697 +
698 return string(etag), nil
699 }
700 return "", nil