Open WithoutPants opened 4 years ago
Added the following to TestXPath in query_test.go:
TestXPath
query_test.go
_, err := QueryAll(testDoc, "$test/@attr")
I'd expect this to return an error during parsing due to the badly formed xpath. Instead, it causes a panic:
--- FAIL: TestXPath (0.00s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x18 pc=0x543fd5] goroutine 15 [running]: testing.tRunner.func1.1(0x7423c0, 0xaee130) c:/go/src/testing/testing.go:940 +0x2fc testing.tRunner.func1(0xc000111200) c:/go/src/testing/testing.go:943 +0x400 panic(0x7423c0, 0xaee130) c:/go/src/runtime/panic.go:969 +0x174 github.com/antchfx/xpath.(*attributeQuery).Clone(0xc0000054c0, 0xc000005520, 0x728220) C:/Users/.../go/pkg/mod/github.com/antchfx/xpath@v1.1.6/query.go:164 +0x35 github.com/antchfx/xpath.(*Expr).Select(...) C:/Users/.../go/pkg/mod/github.com/antchfx/xpath@v1.1.6/xpath.go:131 github.com/antchfx/htmlquery.QuerySelectorAll(0xc00010a230, 0xc0000054e0, 0xc0000054e0, 0x0, 0x0) D:/dev/htmlquery/query.go:82 +0x91 github.com/antchfx/htmlquery.QueryAll(0xc00010a230, 0x7ad043, 0xb, 0xc000191500, 0x0, 0x0, 0xa2b565, 0x1c) D:/dev/htmlquery/query.go:54 +0x8c github.com/antchfx/htmlquery.TestXPath(0xc000111200) D:/dev/htmlquery/query_test.go:150 +0x2c1 testing.tRunner(0xc000111200, 0x7cbd00) c:/go/src/testing/testing.go:991 +0xe3 created by testing.(*T).Run c:/go/src/testing/testing.go:1042 +0x35e exit status 2 FAIL github.com/antchfx/htmlquery 0.270s
Added the following to
TestXPath
inquery_test.go
:I'd expect this to return an error during parsing due to the badly formed xpath. Instead, it causes a panic: