mirror of
https://github.com/golang/go
synced 2024-11-22 21:40:03 -07:00
Wrap kludge text in HTML comments so the text/html output will remain valid HTML.
Be more conservative: only mess with text/html and text/plain output. R=rsc APPROVED=rsc DELTA=20 (12 added, 5 deleted, 3 changed) OCL=33806 CL=33812
This commit is contained in:
parent
fdc4b4a47f
commit
429157848f
@ -209,11 +209,6 @@ func errorKludge(c *Conn, req *Request) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Is it text? ("Content-Type" is always in the map)
|
||||
if s := c.header["Content-Type"]; len(s) < 5 || s[0:5] != "text/" {
|
||||
return;
|
||||
}
|
||||
|
||||
// Is it a broken browser?
|
||||
var msg string;
|
||||
switch agent := req.UserAgent; {
|
||||
@ -225,10 +220,22 @@ func errorKludge(c *Conn, req *Request) {
|
||||
return;
|
||||
}
|
||||
msg += " would ignore this error page if this text weren't here.\n";
|
||||
|
||||
// Is it text? ("Content-Type" is always in the map)
|
||||
baseType := strings.Split(c.header["Content-Type"], ";", 2)[0];
|
||||
switch baseType {
|
||||
case "text/html":
|
||||
io.WriteString(c, "<!-- ");
|
||||
for c.written < min {
|
||||
io.WriteString(c, msg);
|
||||
}
|
||||
io.WriteString(c, " -->");
|
||||
case "text/plain":
|
||||
io.WriteString(c, "\n");
|
||||
for c.written < min {
|
||||
io.WriteString(c, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) flush() {
|
||||
|
Loading…
Reference in New Issue
Block a user