Skip to content

html/template: matches DOCTYPE in a case-sensitive manner. Should be insensitive. #3094

@gopherbot

Description

@gopherbot

by wlott@imbaent.com:

What steps will reproduce the problem?

package main
import (
    "html/template"
    "os"
)
func main() {
    t1,_ := template.New("works").Parse("<!DOCTYPE html><html></html>\n")
    t1.Execute(os.Stdout, nil)
    t2,_ := template.New("fails").Parse("<!doctype html><html></html>\n")
    t2.Execute(os.Stdout, nil)
}


What is the expected output?

<!DOCTYPE html><html></html>
<!doctype html><html></html>

What do you see instead?

<!DOCTYPE html><html></html>
&lt;!doctype html><html></html>

Which compiler are you using (5g, 6g, 8g, gccgo)?

Don't know, whatever "go run" uses internally.

Which operating system are you using?

Windows (x64)

Which revision are you using?  (hg identify)

Prebuilt, downloaded from:
    http://code.google.com/p/gomingw/downloads/detail?name=gowinamd64_weekly.2012-02-14.zip&;can=2&q=

Please provide any additional information below.

Line 577 of src/pkg/html/template/escape.go:
    var doctypeBytes = []byte("<!DOCTYPE")
and line 596:
    if s[j] == '<' && !bytes.HasPrefix(s[j:], doctypeBytes) {
look like they are just checking for fixed bytes without normalizing the case.
    http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#the-doctype
clearly says the check should be case insensitive.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions