diff --git a/src/net/http/fs.go b/src/net/http/fs.go index af7511a7a4..678b978b7b 100644 --- a/src/net/http/fs.go +++ b/src/net/http/fs.go @@ -151,6 +151,8 @@ func dirList(w ResponseWriter, r *Request, f File) { sort.Slice(dirs, func(i, j int) bool { return dirs.name(i) < dirs.name(j) }) w.Header().Set("Content-Type", "text/html; charset=utf-8") + fmt.Fprintf(w, "\n") + fmt.Fprintf(w, "\n") fmt.Fprintf(w, "
\n")
 	for i, n := 0, dirs.len(); i < n; i++ {
 		name := dirs.name(i)
diff --git a/src/net/http/fs_test.go b/src/net/http/fs_test.go
index 861e70caf2..383d27df9b 100644
--- a/src/net/http/fs_test.go
+++ b/src/net/http/fs_test.go
@@ -325,7 +325,7 @@ func TestFileServerCleans(t *testing.T) {
 
 func TestFileServerEscapesNames(t *testing.T) { run(t, testFileServerEscapesNames) }
 func testFileServerEscapesNames(t *testing.T, mode testMode) {
-	const dirListPrefix = "
\n"
+	const dirListPrefix = "\n\n
\n"
 	const dirListSuffix = "\n
\n" tests := []struct { name, escaped string