gregorrr / anki-auto-markdown

37 stars 9 forks source link

Exception with Cyrillic characters in URL #17

Open NSBum opened 4 years ago

NSBum commented 4 years ago

Throws an exception when attempting to add URL's containing Russian letters. For example

https://en.wiktionary.org/wiki/выпускаться#Russian

throws this exception:

Error 
An error occurred. Please start Anki...blah blah blah
Debug info:
Anki 2.1.15 (442df9d6) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.14.6
Flags: frz=True ao=True sv=2
Add-ons possibly involved: Auto Markdown, Frozen Fields
Caught exception:
  File "aqt/webview.py", line 27, in cmd
  File "aqt/webview.py", line 87, in _onCmd
  File "aqt/webview.py", line 368, in _onBridgeCmd
  File "<decorator-gen-58>", line 2, in onBridgeCmd
  File "anki/hooks.py", line 74, in decorator_wrapper
  File "anki/hooks.py", line 71, in repl
  File "/Users/alan/Library/Application Support/Anki2/addons21/516643804/main.py", line 212, in onBridge
    return _old(self, str)
  File "aqt/editor.py", line 273, in onBridgeCmd
  File "anki/hooks.py", line 39, in runFilter
  File "/Users/alan/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 228, in editFocusLostFilter
    isGenerated = fieldIsGeneratedHtml(field_html)
  File "/Users/alan/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 78, in fieldIsGeneratedHtml
    tree = BeautifulSoup(field_html, 'html.parser')
  File "bs4/__init__.py", line 274, in __init__
  File "bs4/__init__.py", line 336, in _check_markup_is_url
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/warnings.py", line 101, in _showwarnmsg
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/warnings.py", line 30, in _showwarnmsg_impl
  File "aqt/errors.py", line 41, in write
<class 'UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 104-113: ordinal not in range(128)
suvernev-d commented 4 years ago

I'm using Cyrillics a lot, but could not reproduce this (Anki is 2.1.18). Maybe the issue is in Frozen Fields add-on?