aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJes Cok <xigua67damn@gmail.com>2024-03-28 22:33:37 +0800
committerThan McIntosh <thanm@google.com>2024-03-29 00:17:10 +0000
commitbb523c9542e2848dfa403d0d84c759ad771e9d69 (patch)
tree66e94795f0f9ff95aedeece022a04a18b0428fa0
parent8f618c1f5329bd81912f8f776cb8bf028c750687 (diff)
downloadgo-bb523c9542e2848dfa403d0d84c759ad771e9d69.tar.gz
go-bb523c9542e2848dfa403d0d84c759ad771e9d69.zip
net/http: correct doc for ServeFileFS
The documentation of ServeFileFS was partly copied from ServeFile in CL 513956, however it's not exact. This CL fixes some typos, also removes obsolete comment for name param. For consistency, also adds godoc link for ServeFile and ServeContent. Fixes #66578 Change-Id: I87147d72c533d46284f06ef20b37fdafa8706710 Reviewed-on: https://go-review.googlesource.com/c/go/+/575016 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
-rw-r--r--src/net/http/fs.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/net/http/fs.go b/src/net/http/fs.go
index 45cf16eed11..25e9406a581 100644
--- a/src/net/http/fs.go
+++ b/src/net/http/fs.go
@@ -747,7 +747,7 @@ func localRedirect(w ResponseWriter, r *Request, newPath string) {
// If the provided file or directory name is a relative path, it is
// interpreted relative to the current directory and may ascend to
// parent directories. If the provided name is constructed from user
-// input, it should be sanitized before calling ServeFile.
+// input, it should be sanitized before calling [ServeFile].
//
// As a precaution, ServeFile will reject requests where r.URL.Path
// contains a ".." path element; this protects against callers who
@@ -779,22 +779,20 @@ func ServeFile(w ResponseWriter, r *Request, name string) {
// ServeFileFS replies to the request with the contents
// of the named file or directory from the file system fsys.
//
-// If the provided file or directory name is a relative path, it is
-// interpreted relative to the current directory and may ascend to
-// parent directories. If the provided name is constructed from user
-// input, it should be sanitized before calling [ServeFile].
+// If the provided name is constructed from user input, it should be
+// sanitized before calling [ServeFileFS].
//
-// As a precaution, ServeFile will reject requests where r.URL.Path
+// As a precaution, ServeFileFS will reject requests where r.URL.Path
// contains a ".." path element; this protects against callers who
// might unsafely use [filepath.Join] on r.URL.Path without sanitizing
// it and then use that filepath.Join result as the name argument.
//
-// As another special case, ServeFile redirects any request where r.URL.Path
+// As another special case, ServeFileFS redirects any request where r.URL.Path
// ends in "/index.html" to the same path, without the final
// "index.html". To avoid such redirects either modify the path or
-// use ServeContent.
+// use [ServeContent].
//
-// Outside of those two special cases, ServeFile does not use
+// Outside of those two special cases, ServeFileFS does not use
// r.URL.Path for selecting the file or directory to serve; only the
// file or directory provided in the name argument is used.
func ServeFileFS(w ResponseWriter, r *Request, fsys fs.FS, name string) {