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

Corpus Viewer: Sanitize bad regex #1068

Open
ajdapretnar opened this issue Jul 1, 2024 · 0 comments
Open

Corpus Viewer: Sanitize bad regex #1068

ajdapretnar opened this issue Jul 1, 2024 · 0 comments

Comments

@ajdapretnar
Copy link
Collaborator

Describe the bug
Corpus Viewer crashes on bad regex.

------------------------------- error Exception -------------------------------
Traceback (most recent call last):
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/orangewidget/gui.py", line 993, in returnPressedHandler
    self.__callback_if_changed()
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/orangewidget/gui.py", line 1001, in __callback_if_changed
    self.callback()
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/orangecontrib/text/widgets/owcorpusviewer.py", line 591, in refresh_search
    self.doc_list.model().set_filter_string(self.regexp_filter)
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/orangecontrib/text/widgets/owcorpusviewer.py", line 189, in set_filter_string
    self.__regex = re.compile(filter_string.strip("|"), re.IGNORECASE)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/__init__.py", line 227, in compile
    return _compile(pattern, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/__init__.py", line 294, in _compile
    p = _compiler.compile(pattern, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_compiler.py", line 745, in compile
    p = _parser.parse(p, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_parser.py", line 989, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_parser.py", line 464, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_parser.py", line 548, in _parse
    code = _escape(source, this, state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Orange.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/_parser.py", line 396, in _escape
    raise source.error("incomplete escape %s" % escape, len(escape))
re.error: incomplete escape \u at position 0
-------------------------------------------------------------------------------

To Reproduce
Open Corpus Viewer with any corpus, enter \u in the search box, press Enter.

Expected behavior
A Warning occurs.

Orange version:
3.37.0

Text add-on version:
1.15.0

Operating system:
OSX

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