Do not use shlex for splitting as it breaks on torrents containing quotes

This commit is contained in:
Asmageddon 2012-05-26 20:02:08 +02:00
parent fa1a1eb939
commit d7391611dd
2 changed files with 3 additions and 4 deletions

View File

@ -38,7 +38,7 @@ import os
import sys import sys
import logging import logging
import optparse import optparse
import shlex import re
import locale import locale
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
@ -163,7 +163,7 @@ class BaseCommand(object):
def split(self, text): def split(self, text):
if deluge.common.windows_check(): if deluge.common.windows_check():
text = text.replace('\\', '\\\\') text = text.replace('\\', '\\\\')
return shlex.split(text) return re.split(r"(?<!\\) ", text)
def create_parser(self): def create_parser(self):
return OptionParser(prog = self.name, return OptionParser(prog = self.name,

View File

@ -52,7 +52,6 @@ strwidth = format_utils.strwidth
import logging,os import logging,os
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
import shlex
import re import re
LINES_BUFFER_SIZE = 5000 LINES_BUFFER_SIZE = 5000
@ -602,7 +601,7 @@ class Legacy(BaseMode):
p = " ".join(split(line)[:-1]) p = " ".join(split(line)[:-1])
try: try:
l_arg = shlex.split(line)[-1] l_arg = split(line)[-1]
except IndexError: except IndexError:
l_arg = "" l_arg = ""