dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.

Home Page:http://mycli.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`alias_dsn` crashes when the password contains a comma `,`.

your-diary opened this issue · comments

commented

My ~/.myclirc has this:

[alias_dsn]
test_1 = mysql://user:password@localhost:3306/db
test_2 = mysql://user:,@localhost:3306/db

The first alias works:

$ mycli -D test_1
(2003, "Can't connect to MySQL server on 'localhost' ([Errno 61] Connection refused)")

The second alias crashes:

$ mycli -D test_2
Traceback (most recent call last):
  File "/opt/homebrew/bin/mycli", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/mycli/1.27.0/libexec/lib/python3.12/site-packages/mycli/main.py", line 1278, in cli
    uri = urlparse(dsn_uri)
          ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.2/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/parse.py", line 394, in urlparse
    url, scheme, _coerce_result = _coerce_args(url, scheme)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.2/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/parse.py", line 133, in _coerce_args
    return _decode_args(args) + (_encode_result,)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.2/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/parse.py", line 117, in _decode_args
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.2/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/parse.py", line 117, in <genexpr>
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
                 ^^^^^^^^
AttributeError: 'list' object has no attribute 'decode'
commented

Quoting worked like a charm:

[alias_dsn]
test_1 = mysql://user:password@localhost:3306/db
test_2 = 'mysql://user:,@localhost:3306/db'