-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XPath syntax problems should make the query fail before execution #541
Comments
I'm closing so far. Looks that the problem was during parsing a blob (missed escaped characters). |
@kuba-- jfyi there already is an API for validating XPath in SDK import github.com/bblfsh/sdk/uast/query/xpath
idx := xpath.New()
q, err := idx.Prepare("//uast:Identifier")
if err != nil {
//handle it
}
q.Execute(uast) And ofc upon feature request in a new issue it can be exposed in client-go. |
@bzz - we've already used a new stuff. Look at my comments: #635 The problem is the 3rd party library (https://github.com/antchfx/xpath/blob/master/xpath.go#L139). func TestBblfsh(t *testing.T) {
var err error
var x *Expr
x, err = Compile("//*[@role=\"Return\"]")
if err != nil {
t.Fatalf("should be correct but got error %s", err)
}
t.Logf("%v\n", x)
x, err = Compile("BAD")
if err != nil {
t.Fatalf("should be correct but got error %s", err)
}
t.Logf("%v\n", x)
x, err = Compile("this is a totally crap. For sure not valid @xpath")
if err != nil {
t.Fatalf("should be correct but got error %s", err)
}
t.Logf("%v\n", x)
x, err = Compile("//*")
if err != nil {
t.Fatalf("should be correct but got error %s", err)
}
t.Logf("%v\n", x)
/*
x, err = Compile("")
if err != nil {
t.Fatalf("should be correct but got error %s", err)
}
t.Logf("%v\n", x)
*/
} |
Using double quotes here
'//*[@role="Return"]'
will make the XPath expression not valid:It would be good to validate this during analysis and fail.
The text was updated successfully, but these errors were encountered: