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

Filter crashes curitz on invalid regex subpattern match with eg. ( and ) characters #2

Open
runborg opened this issue Mar 25, 2024 · 0 comments

Comments

@runborg
Copy link
Contributor

runborg commented Mar 25, 2024

if trying to search for a string including a not regex valid set of ( and ) characters makes curitz exit with a traceback:

--> $ curitz
Traceback (most recent call last):
  File "/home/runarb/.local/bin/curitz", line 8, in <module>
    sys.exit(main())
  File "/home/runarb/.local/pipx/venvs/curitz/lib/python3.10/site-packages/curitz/cli.py", line 1182, in main
    curses.wrapper(uiloop, config)
  File "/usr/lib/python3.10/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/runarb/.local/pipx/venvs/curitz/lib/python3.10/site-packages/curitz/cli.py", line 404, in uiloop
    runner(screen, config)
  File "/home/runarb/.local/pipx/venvs/curitz/lib/python3.10/site-packages/curitz/cli.py", line 865, in runner
    create_case_list(config)
  File "/home/runarb/.local/pipx/venvs/curitz/lib/python3.10/site-packages/curitz/cli.py", line 454, in create_case_list
    sorted_cases = sortCases(cases, field="updated", filter=casefilter)
  File "/home/runarb/.local/pipx/venvs/curitz/lib/python3.10/site-packages/curitz/cli.py", line 420, in sortCases
    if re.match(
  File "/usr/lib/python3.10/re.py", line 190, in match
    return _compile(pattern, flags).match(string)
  File "/usr/lib/python3.10/re.py", line 303, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.10/sre_compile.py", line 788, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.10/sre_parse.py", line 955, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.10/sre_parse.py", line 444, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.10/sre_parse.py", line 843, in _parse
    raise source.error("missing ), unterminated subpattern",
re.error: missing ), unterminated subpattern at position 5

This happens because the string entered is passed right into a regex without error handling,
Entering a incomplete subpattern should generate a better error message to the user.

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

1 participant