Skip to content
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

"panic: regexp: Compile" while using invalid regex #3

Closed
evakhoni opened this issue May 9, 2022 · 2 comments
Closed

"panic: regexp: Compile" while using invalid regex #3

evakhoni opened this issue May 9, 2022 · 2 comments

Comments

@evakhoni
Copy link

evakhoni commented May 9, 2022

jf version 1.1.0 / fedora 35

  • description: passing an invalid regex to jf causing it to crash and dump stack

  • reproducible: 100%

  • steps: jsonfind -r "?" any-json-file.json

  • expected result: simple error like: 'regex search term is invalid'

  • actual result:

panic: regexp: Compile(?): error parsing regexp: missing argument to repetition operator: ?

goroutine 1 [running]:
regexp.MustCompile({0x7ffdd06cf1bb, 0x1})
/usr/local/Cellar/go/1.18.1/libexec/src/regexp/regexp.go:317 +0xbb
jsonfind/pkg/scout.(*Scout).isAMatch(0x5a0ca9?, {0xc0001360f0, 0x4c})
/Users/anthonyfox/dev/jsonfind/pkg/scout/scout.go:77 +0x5c
jsonfind/pkg/scout.(*Scout).parseMap(0xc0000f7d30, 0x2?, {0xc0000b6480, 0x37})
/Users/anthonyfox/dev/jsonfind/pkg/scout/scout.go:49 +0x1fd
jsonfind/pkg/scout.(*Scout).parseMap(0xc0000f7d30, 0x2?, {0xc0000bc770, 0x6})
/Users/anthonyfox/dev/jsonfind/pkg/scout/scout.go:45 +0x15d
jsonfind/pkg/scout.(*Scout).parseMap(0xc0000f7d30, 0x2?, {0x0, 0x0})
/Users/anthonyfox/dev/jsonfind/pkg/scout/scout.go:45 +0x15d
jsonfind/pkg/scout.(*Scout).DoSearch(0xc0000f7d30)
/Users/anthonyfox/dev/jsonfind/pkg/scout/scout.go:33 +0x4e
main.entrypoint(0xc0000ba5c0)
/Users/anthonyfox/dev/jsonfind/cmd/jf/main.go:68 +0x25c
github.com/urfave/cli/v2.(*App).RunContext(0xc000112000, {0x5e2328?, 0xc0000bc020}, {0xc0000ba040, 0x4, 0x4})
/Users/anthonyfox/dev/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/app.go:315 +0x9cc
github.com/urfave/cli/v2.(*App).Run(...)
/Users/anthonyfox/dev/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/app.go:215
main.main()
/Users/anthonyfox/dev/jsonfind/cmd/jf/main.go:48 +0x305

@WTFox
Copy link
Owner

WTFox commented May 9, 2022

Completely agree. This should be gracefully handled. Thanks for the issue!

@WTFox
Copy link
Owner

WTFox commented May 9, 2022

New version published. Thanks again for using jsonfind and finding things I missed. ❤️

@WTFox WTFox closed this as completed May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants