also trim in context query
@@ -10,9 +10,14 @@ import (
//Query the JSON context with JMESPATH search path
func (ctx *Context) Query(query string) (interface{}, error) {
+ query = strings.TrimSpace(query)
+ if query == "" {
+ return nil, fmt.Errorf("invalid query (nil)")
+ }
+
var emptyResult interface{}
// check for white-listed variables
- if !ctx.isWhiteListed(query) {
+ if !ctx.isBuiltInVariable(query) {
return emptyResult, fmt.Errorf("variable %s cannot be used", query)
}
@@ -40,7 +45,7 @@ func (ctx *Context) Query(query string) (interface{}, error) {
return result, nil
}
-func (ctx *Context) isWhiteListed(variable string) bool {
+func (ctx *Context) isBuiltInVariable(variable string) bool {
if len(ctx.builtInVars) == 0 {
return true
}
