Skip to content

Commit f161093

Browse files
committed
Removed newline characters from precomputed etags
1 parent 8e0d3e1 commit f161093

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

modules/caddyhttp/fileserver/staticfiles.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package fileserver
1616

1717
import (
18+
"bytes"
1819
"errors"
1920
"fmt"
2021
"io"
@@ -690,6 +691,10 @@ func (fsrv *FileServer) getEtagFromFile(fileSystem fs.FS, filename string) (stri
690691
if err != nil {
691692
return "", fmt.Errorf("cannot read etag from file %s: %v", etagFilename, err)
692693
}
694+
695+
// Etags should not contain newline characters
696+
etag = bytes.ReplaceAll(etag, []byte("\n"), []byte(""))
697+
693698
return string(etag), nil
694699
}
695700
return "", nil

0 commit comments

Comments
 (0)