errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.08k stars 607 forks source link

Plugin config through Slack fails because of Unicode characters #1690

Closed jcfrt closed 3 days ago

jcfrt commented 2 months ago

Describe the bug Using !plugin config MyPlugin {"key": "value"} from the Slack client does not work because the Slack client (on MacOS) forces the use of unicode characters for double and single quotes:

Getting the following error in logs:

ERROR    errbot.plugins.Plugins    Invalid expression for the configuration of the plugin
Traceback (most recent call last):
  File "errbot/core_plugins/plugins.py", line 187, in plugin_config
    real_config_obj = literal_eval(" ".join(args[1:]))
  File "/usr/local/lib/python3.10/ast.py", line 62, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
  File "/usr/local/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    {<E2><80><98>key<E2><80><99>: <E2><80><98>value<E2><80><99>}
     ^
SyntaxError: invalid character '<E2><80><98>' (U+2018)

To Reproduce

Expected behavior The character string polluted with unicode should be parsed; unicode characters replaced with ASCII equivalent.

Environment (please complete the following information):

jcfrt commented 2 months ago

Found a workaround: disable the smart quotes feature globally in MacOS

# Disable smart quotes as they’re annoying when typing code.
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false