Skip to content

encoding/xml: accepts invalid XML with multiple colons #20396

Closed
@santhosh-tekuri

Description

@santhosh-tekuri

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.1 darwin/amd64

What operating system and processor architecture are you using (go env)?

darwin/amd64

What did you do?

<a:te:st xmlns:a="abcd"/>

parsing above xml with golang standard lib, does not report any error
go program used to test: (https://play.golang.org/p/j_VigKalfk)

package main

import (
	"encoding/xml"
	"fmt"
	"io"
	"strings"
)

func main() {
	decoder := xml.NewDecoder(strings.NewReader(`<a:te:st xmlns:a="abcd"/>`))
	for {
		t, err := decoder.Token()
		if err != io.EOF && err != nil {
			fmt.Println("invalid xml", err)
			break
		}
		if t == nil {
			break
		}
	}
}

with xmllint linux program, it reports invalid xml

$xmllint test.xml
test.xml:1: namespace error : Failed to parse QName 'a:te:'
<a:te:st xmlns:a="abcd"/>
     ^
<?xml version="1.0"?>
<a:te:st xmlns:a="abcd"/>

What did you expect to see?

should report error in parsing xml

What did you see instead?

parses without any error

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions