13 Commits

Author SHA1 Message Date
Erik Dubbelboer 8fe6af3619 Fix flaky race tests (#2292)
* Fix flaky race tests

* Drain streamed body in content length test
2026-06-13 09:00:14 +02:00
Erik Dubbelboer 289229aad3 bug: FS cache cleaner goroutine leaks when CleanStop is nil (default) (#2218), #2247 (#2271) 2026-06-06 11:00:24 +02:00
Erik Dubbelboer 267e740f56 fs: reject '..' path segments in rewritten paths (#2173)
Rewritten FS paths were only checked for the "/../" substring, which
allowed leading "../" values to bypass the traversal guard.

Reject any rewritten path containing a ".." path segment before joining
it with FS.Root. This closes the PathRewrite/NewPathPrefixStripper escape
in the default OS-backed handler and keeps rewritten paths within the
intended static root.

This vulnerability was discovered and reported by bugbunny.ai
2026-04-05 07:03:25 +02:00
Erik Dubbelboer d64d07686a Prevent unnecessary logging during tests 2026-03-23 05:18:59 +01:00
Erik Dubbelboer d238e60fed Add ServeFileLiteral, ServeFSLiteral and SendFileLiteral (#2163)
ServeFile and ServeFS interpret the path as a URI, so percent-encoded
sequences are decoded and characters like '?' and '#' act as URI
delimiters. This makes it impossible to serve files whose names
contain those characters.

Changing this behavior would be backwards incompatible. So instead the
new ServeFileLiteral, ServeFSLiteral and SendFileLiteral are added.

The new Literal variants percent-encode the path before setting it as
the request URI, preserving every byte of the original filesystem path.

Thanks to @thesmartshadow for reporting this issue.
2026-03-23 03:21:36 +01:00
Erik Dubbelboer 1d3c69196c Honor Root for fs.FS and normalize fs-style roots (#2145)
- Apply `fs.Root` in non-`os.FS` path resolution.
- Normalize `fs.FS` roots (`./`, trailing slash, leading slash, separators).
- Handle `PathRewrite` outputs without a leading slash.
- Add tests for `MapFS` and `DirFS` root enforcement.
2026-02-22 18:15:07 +01:00
Erik Dubbelboer c2b317d47d Go 1.26 and golangci-lint updates (#2146)
Keep Go 1.24 compatibility for now (by not using `wg.Go()`).
2026-02-21 10:28:39 +01:00
Erik Dubbelboer 69dc7b1280 Update the supported version to the same as Go itself (#1967)
Some of our dependences require the supported versions of Go.

For example github.com/golang/crypto now requires 1.23 or higher.
See: https://github.com/golang/crypto/commit/89ff08d67c4d79f9ac619aaf1f7388888798651fa

For more information on the new policy of the Go team see: https://github.com/golang/go/issues/69095

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-26 04:39:17 +01:00
Ivan Gabaldon 8e25db024a fix: compression priority (#1950)
* Initial update

* update remaining tests

* update .gitignore

* update another test, fix linting

* fix tests

* add missing Vary header
2025-02-12 14:58:38 +09:00
M. Efe Çetin aadadb913a fs: fix GenerateIndexPages when DirFS or embed.FS is used (#1778) 2024-05-18 10:30:01 +02:00
Oleksandr Redko 190204cf1a Upgrade golangci-lint to v1.56.2; fix gocritic issues (#1722) 2024-02-21 05:51:28 +01:00
Oleksandr Redko 9d6b470260 chore: Add missing dots at the end of comments (#1677) 2023-12-13 13:56:24 +08:00
Tiago Peczenyj 4010b16eef Add support to fs.fs on serve static files (#1640)
* substitute *os.File by fs.File

* refactor error handling by using the new recommended form

* finish implementation

* substitute seek(offset,0) by seek(offset, io.SeekStart)

* add unit test

* use io.SeekStart on Seek method
2023-11-05 14:46:42 +01:00