glutanimate / review-heatmap

Anki add-on to help you keep track of your review activity
https://ankiweb.net/shared/info/1771074083
Other
1.2k stars 90 forks source link

Sanitize search input when using rid field search #29

Open glutanimate opened 5 years ago

glutanimate commented 5 years ago

Review Heatmap currently expects a properly formatted rid query, erroring out in case of some added characters:

Caught exception:
  File "aqt\progress.py", line 67, in handler
  File "aqt\browser.py", line 597, in _onSearchActivated
  File "aqt\browser.py", line 608, in search
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\874215009\advancedbrowser\core.py", line 116, in search
    super(AdvancedDataModel, self).search(txt)
  File "<decorator-gen-72>", line 2, in search
  File "anki\hooks.py", line 74, in decorator_wrapper
  File "anki\hooks.py", line 71, in repl
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\1924690148\__init__.py", line 37, in mySearch
    _old(self, txt)
  File "aqt\browser.py", line 133, in search
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\874215009\advancedbrowser\core.py", line 158, in myFindCards
    preds, args = finder._where(tokens)
  File "anki\find.py", line 178, in _where
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\review_heatmap\links.py", line 123, in findRevlogEntries
    cutoff1, cutoff2 = [int(i) for i in args.split(":")]
  File "C:\Users\Khonkhortisan\AppData\Roaming\Anki2\addons21\review_heatmap\links.py", line 123, in <listcomp>
    cutoff1, cutoff2 = [int(i) for i in args.split(":")]
<class 'ValueError'>: invalid literal for int() with base 10: '1549008000000j'

We should properly sanitize the search string before moving on.

glutanimate commented 5 years ago

Thanks to @khonkhortisan for the report!