Opened 8 weeks ago

Last modified 8 weeks ago

#3647 new bug

deluge console errors on addition of torrent with semicolon (`;`) in name

Reported by: iconoclasthero Owned by:
Priority: minor Milestone: needs verified
Component: Unknown Version: 2.0.5
Keywords: Cc:

Description

$ deluge-console --version
deluge-console 2.1.1
libtorrent: 2.0.11.0
Python: 3.12.9
OS: Linux 6.13.2-061302-generic

Background: script to create torrents and add them to deluged via deluge-console.

Create a torrent with transmission-cli:

Creating torrent "/library/torrent/Last1, First1; Last2, First2 -- Title, 3_e (1989, 2016).torrent"
2 files, 84.84 MB
1,295 pieces, 65.54 kB each
 done!
torrentfile=/library/torrent/Last1, First1; Last2, First2 -- Title, 3_e (1989, 2016).torrent

The next step is to add the torrent to deluge via deluge-console:

deluge-console "connect $delugehost:$delugeport $delugeuser $delugepass; add -p ${linked@Q} ${torrentfile@Q}"
Traceback (most recent call last):
  File "/home/user/.local/bin/deluge-console", line 8, in <module>
    sys.exit(start())
             ^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/__init__.py", line 16, in start
    return Console().start()
           ^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/console.py", line 148, in start
    super().start(self.console_parser)
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/ui.py", line 64, in start
    self.__options = self.parse_args(parser, args)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/ui.py", line 43, in parse_args
    options = parser.parse_args(args)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/parser.py", line 73, in parse_args
    multi_command = self._split_args(args)
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/parser.py", line 50, in _split_args
    cmds = shlex.split(cmd_line)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 313, in split
    return list(lex)
           ^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 300, in __next__
    token = self.get_token()
            ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 109, in get_token
    raw = self.read_token()
          ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation

changing torrentfile to specifically escape the semicolon does not help:

torrentfile=/library/torrent/Last1, First1\; Last2, First2 -- Title, 3_e (1989, 2016).torrent

Change History (3)

comment:1 by iconoclasthero, 8 weeks ago

Summary: deluge console errors on addition of torrent with `;` in namedeluge console errors on addition of torrent with semicolon (`;`) in name

comment:2 by iconoclasthero, 8 weeks ago

NB: the @Q wraps the semicolon-containing string in single quotes which I thought should be enough:

echo "${torrentfile@Q}"
'/library/torrent/Last1, First1; Last2, First2 -- Title, 3_e (1989, 2016).torrent'

comment:3 by iconoclasthero, 8 weeks ago

Also this fails...

$ deluge-console "connect $delugehost:$delugeport $delugeuser $delugepass; add -p ${linked@Q} \"${torrentfile//\;/\\\;}\""
Traceback (most recent call last):
  File "/home/user/.local/bin/deluge-console", line 8, in <module>
    sys.exit(start())
             ^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/__init__.py", line 16, in start
    return Console().start()
           ^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/console.py", line 148, in start
    super().start(self.console_parser)
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/ui.py", line 64, in start
    self.__options = self.parse_args(parser, args)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/ui.py", line 43, in parse_args
    options = parser.parse_args(args)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/parser.py", line 73, in parse_args
    multi_command = self._split_args(args)
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/deluge/lib/python3.12/site-packages/deluge/ui/console/parser.py", line 50, in _split_args
    cmds = shlex.split(cmd_line)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 313, in split
    return list(lex)
           ^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 300, in __next__
    token = self.get_token()
            ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 109, in get_token
    raw = self.read_token()
          ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/shlex.py", line 210, in read_token
    raise ValueError("No escaped character")
ValueError: No escaped character

defining "$torrentfile" as also does not work:

torrentfile=/library/torrent/Last1\,\ First1\;\ Last2\,\ First2\ --\ Title\,\ 3_e\ \(1989\,\ 2016\).torrent
Note: See TracTickets for help on using tickets.