Skip to content

Commit

Permalink
fileserver: Remove newline characters from precomputed etags (#6394)
Browse files Browse the repository at this point in the history
* Removed newline characters from precomputed etags

* Update modules/caddyhttp/fileserver/staticfiles.go

---------

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
  • Loading branch information
armadi1809 and mholt authored Jun 19, 2024
1 parent 99dcdf7 commit c2ccf86
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/caddyhttp/fileserver/staticfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package fileserver

import (
"bytes"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c2ccf86

Please sign in to comment.