|
|
36ae71 |
From 9956bdb4d904a523381d3971796e829721e84e29 Mon Sep 17 00:00:00 2001
|
|
|
36ae71 |
From: Jiri Popelka <jpopelka@redhat.com>
|
|
|
36ae71 |
Date: Thu, 27 Feb 2014 18:38:43 +0100
|
|
|
36ae71 |
Subject: [PATCH] prevent argparse from parsing iptables options
|
|
|
36ae71 |
|
|
|
36ae71 |
since 2f435f7a
|
|
|
36ae71 |
--direct --passthrough ipv4 --table filter --delete INPUT --jump ACCEPT
|
|
|
36ae71 |
has been failing with:
|
|
|
36ae71 |
error: ambiguous option: --delete could match --delete-icmptype,
|
|
|
36ae71 |
--delete-service, --delete-zone
|
|
|
36ae71 |
---
|
|
|
36ae71 |
src/firewall-cmd | 55 ++++++++++++++++++++++++++++++------------
|
|
|
36ae71 |
src/firewall-offline-cmd | 41 +++++++++++++++++++++++--------
|
|
|
36ae71 |
src/firewall/functions.py | 2 +-
|
|
|
36ae71 |
src/tests/firewall-cmd_test.sh | 10 +++++++-
|
|
|
36ae71 |
4 files changed, 81 insertions(+), 27 deletions(-)
|
|
|
36ae71 |
|
|
|
36ae71 |
diff --git a/src/firewall-cmd b/src/firewall-cmd
|
|
|
36ae71 |
index 029e2b7..aa7e3c0 100755
|
|
|
36ae71 |
--- a/src/firewall-cmd
|
|
|
36ae71 |
+++ b/src/firewall-cmd
|
|
|
36ae71 |
@@ -31,7 +31,7 @@ import os
|
|
|
36ae71 |
|
|
|
36ae71 |
from firewall.client import *
|
|
|
36ae71 |
from firewall.errors import *
|
|
|
36ae71 |
-from firewall.functions import joinArgs
|
|
|
36ae71 |
+from firewall.functions import joinArgs, splitArgs
|
|
|
36ae71 |
|
|
|
36ae71 |
def __print(msg=None):
|
|
|
36ae71 |
if msg and not a.quiet:
|
|
|
36ae71 |
@@ -473,7 +473,7 @@ parser_direct.add_argument("--remove-passthrough", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
parser_direct.add_argument("--query-passthrough", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", "<args>"))
|
|
|
36ae71 |
parser_direct.add_argument("--get-passthroughs", nargs=1,
|
|
|
36ae71 |
- metavar=("{ ipv4 | ipv6 | eb }", "<args>"))
|
|
|
36ae71 |
+ metavar=("{ ipv4 | ipv6 | eb }"))
|
|
|
36ae71 |
parser_direct.add_argument("--get-all-passthroughs", action="store_true")
|
|
|
36ae71 |
parser_direct.add_argument("--add-chain", nargs=3,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", "", "<chain>"))
|
|
|
36ae71 |
@@ -489,14 +489,39 @@ parser_direct.add_argument("--add-rule", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
parser_direct.add_argument("--remove-rule", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", " <chain> <priority> <args>"))
|
|
|
36ae71 |
parser_direct.add_argument("--remove-rules", nargs=3,
|
|
|
36ae71 |
- metavar=("{ ipv4 | ipv6 | eb }", " <chain> <args>"))
|
|
|
36ae71 |
+ metavar=("{ ipv4 | ipv6 | eb }", " <chain>"))
|
|
|
36ae71 |
parser_direct.add_argument("--query-rule", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", " <chain> <priority> <args>"))
|
|
|
36ae71 |
parser_direct.add_argument("--get-rules", nargs=3,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", "", "<chain>"))
|
|
|
36ae71 |
parser_direct.add_argument("--get-all-rules", action="store_true")
|
|
|
36ae71 |
|
|
|
36ae71 |
-a = parser.parse_args()
|
|
|
36ae71 |
+i = -1
|
|
|
36ae71 |
+args = sys.argv[1:]
|
|
|
36ae71 |
+if '--passthrough' in args:
|
|
|
36ae71 |
+ i = args.index('--passthrough') + 1
|
|
|
36ae71 |
+elif '--add-passthrough' in args:
|
|
|
36ae71 |
+ i = args.index('--add-passthrough') + 1
|
|
|
36ae71 |
+elif '--remove-passthrough' in args:
|
|
|
36ae71 |
+ i = args.index('--remove-passthrough') + 1
|
|
|
36ae71 |
+elif '--query-passthrough' in args:
|
|
|
36ae71 |
+ i = args.index('--query-passthrough') + 1
|
|
|
36ae71 |
+elif '--add-rule' in args:
|
|
|
36ae71 |
+ i = args.index('--add-rule') + 4
|
|
|
36ae71 |
+elif '--remove-rule' in args:
|
|
|
36ae71 |
+ i = args.index('--remove-rule') + 4
|
|
|
36ae71 |
+elif '--query-rule' in args:
|
|
|
36ae71 |
+ i = args.index('--query-rule') + 4
|
|
|
36ae71 |
+# join <args> into one argument to prevent parser from parsing each iptables
|
|
|
36ae71 |
+# option, because they can conflict with firewall-cmd options
|
|
|
36ae71 |
+# # e.g. --delete (iptables) and --delete-* (firewall-cmd)
|
|
|
36ae71 |
+if (i > -1) and (i < len(args) - 1):
|
|
|
36ae71 |
+ aux_args = args[:]
|
|
|
36ae71 |
+ args = aux_args[:i+1] # all but not <args>
|
|
|
36ae71 |
+ args.append(joinArgs(aux_args[i+1:])) # add <args> as one arg
|
|
|
36ae71 |
+
|
|
|
36ae71 |
+a = parser.parse_args(args)
|
|
|
36ae71 |
+
|
|
|
36ae71 |
|
|
|
36ae71 |
options_standalone = a.help or a.version or \
|
|
|
36ae71 |
a.state or a.reload or a.complete_reload or \
|
|
|
36ae71 |
@@ -756,25 +781,25 @@ if a.permanent:
|
|
|
36ae71 |
if len (a.passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --permanent --direct --passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
__print(settings.addPassthrough(_check_ipv(a.passthrough[0]),
|
|
|
36ae71 |
- a.passthrough[1:]))
|
|
|
36ae71 |
+ splitArgs(a.passthrough[1])))
|
|
|
36ae71 |
|
|
|
36ae71 |
if a.add_passthrough:
|
|
|
36ae71 |
if len (a.add_passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --permanent --direct --add-passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
__print(settings.addPassthrough(_check_ipv(a.add_passthrough[0]),
|
|
|
36ae71 |
- a.add_passthrough[1:]))
|
|
|
36ae71 |
+ splitArgs(a.add_passthrough[1])))
|
|
|
36ae71 |
|
|
|
36ae71 |
elif a.remove_passthrough:
|
|
|
36ae71 |
if len (a.remove_passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --permanent --direct --remove-passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
settings.removePassthrough(_check_ipv(a.remove_passthrough[0]),
|
|
|
36ae71 |
- a.remove_passthrough[1:])
|
|
|
36ae71 |
+ splitArgs(a.remove_passthrough[1]))
|
|
|
36ae71 |
elif a.query_passthrough:
|
|
|
36ae71 |
if len (a.query_passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --permanent --direct --query-passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
__print_query_result(
|
|
|
36ae71 |
settings.queryPassthrough(_check_ipv(a.query_passthrough[0]),
|
|
|
36ae71 |
- a.query_passthrough[1:]))
|
|
|
36ae71 |
+ splitArgs(a.query_passthrough[1])))
|
|
|
36ae71 |
sys.exit(0)
|
|
|
36ae71 |
elif a.get_passthroughs:
|
|
|
36ae71 |
rules = settings.getPassthroughs(_check_ipv(a.get_passthroughs[0]))
|
|
|
36ae71 |
@@ -815,7 +840,7 @@ if a.permanent:
|
|
|
36ae71 |
except ValueError:
|
|
|
36ae71 |
__fail("wrong priority\nusage: --permanent --direct --add-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
settings.addRule(_check_ipv(a.add_rule[0]), a.add_rule[1],
|
|
|
36ae71 |
- a.add_rule[2], priority, a.add_rule[4:])
|
|
|
36ae71 |
+ a.add_rule[2], priority, splitArgs(a.add_rule[4]))
|
|
|
36ae71 |
elif a.remove_rule:
|
|
|
36ae71 |
if len (a.remove_rule) < 5:
|
|
|
36ae71 |
__fail("usage: --permanent --direct --remove-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
@@ -824,7 +849,7 @@ if a.permanent:
|
|
|
36ae71 |
except ValueError:
|
|
|
36ae71 |
__fail("usage: --permanent --direct --remove-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
settings.removeRule(_check_ipv(a.remove_rule[0]), a.remove_rule[1],
|
|
|
36ae71 |
- a.remove_rule[2], priority, a.remove_rule[4:])
|
|
|
36ae71 |
+ a.remove_rule[2], priority, splitArgs(a.remove_rule[4]))
|
|
|
36ae71 |
elif a.remove_rules:
|
|
|
36ae71 |
if len (a.remove_rules) < 3:
|
|
|
36ae71 |
__fail("usage: --permanent --direct --remove-rules { ipv4 | ipv6 | eb } <chain>")
|
|
|
36ae71 |
@@ -840,7 +865,7 @@ if a.permanent:
|
|
|
36ae71 |
__print_query_result(
|
|
|
36ae71 |
settings.queryRule(_check_ipv(a.query_rule[0]),
|
|
|
36ae71 |
a.query_rule[1], a.query_rule[2],
|
|
|
36ae71 |
- priority, a.query_rule[4:]))
|
|
|
36ae71 |
+ priority, splitArgs(a.query_rule[4])))
|
|
|
36ae71 |
sys.exit(0)
|
|
|
36ae71 |
elif a.get_rules:
|
|
|
36ae71 |
rules = settings.getRules(_check_ipv(a.get_rules[0]),
|
|
|
36ae71 |
@@ -1032,7 +1057,7 @@ elif a.direct:
|
|
|
36ae71 |
if a.passthrough:
|
|
|
36ae71 |
if len (a.passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --direct --passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
- msg = fw.passthrough(_check_ipv(a.passthrough[0]), a.passthrough[1:])
|
|
|
36ae71 |
+ msg = fw.passthrough(_check_ipv(a.passthrough[0]), splitArgs(a.passthrough[1]))
|
|
|
36ae71 |
if msg:
|
|
|
36ae71 |
print(msg)
|
|
|
36ae71 |
elif a.add_chain:
|
|
|
36ae71 |
@@ -1059,7 +1084,7 @@ elif a.direct:
|
|
|
36ae71 |
except ValueError:
|
|
|
36ae71 |
__fail("wrong priority\nusage: --direct --add-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
fw.addRule(_check_ipv(a.add_rule[0]), a.add_rule[1], a.add_rule[2],
|
|
|
36ae71 |
- priority, a.add_rule[4:])
|
|
|
36ae71 |
+ priority, splitArgs(a.add_rule[4]))
|
|
|
36ae71 |
elif a.remove_rule:
|
|
|
36ae71 |
if len (a.remove_rule) < 5:
|
|
|
36ae71 |
__fail("usage: --direct --remove-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
@@ -1068,7 +1093,7 @@ elif a.direct:
|
|
|
36ae71 |
except ValueError:
|
|
|
36ae71 |
__fail("usage: --direct --remove-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
fw.removeRule(_check_ipv(a.remove_rule[0]),
|
|
|
36ae71 |
- a.remove_rule[1], a.remove_rule[2], priority, a.remove_rule[4:])
|
|
|
36ae71 |
+ a.remove_rule[1], a.remove_rule[2], priority, splitArgs(a.remove_rule[4]))
|
|
|
36ae71 |
elif a.remove_rules:
|
|
|
36ae71 |
if len (a.remove_rules) < 3:
|
|
|
36ae71 |
__fail("usage: --direct --remove-rules { ipv4 | ipv6 | eb } <chain>")
|
|
|
36ae71 |
@@ -1082,7 +1107,7 @@ elif a.direct:
|
|
|
36ae71 |
except ValueError:
|
|
|
36ae71 |
__fail("usage: --direct --query-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
__print_query_result(fw.queryRule(_check_ipv(a.query_rule[0]),
|
|
|
36ae71 |
- a.query_rule[1], a.query_rule[2], priority, a.query_rule[4:]))
|
|
|
36ae71 |
+ a.query_rule[1], a.query_rule[2], priority, splitArgs(a.query_rule[4])))
|
|
|
36ae71 |
elif a.get_rules:
|
|
|
36ae71 |
rules = fw.getRules(_check_ipv(a.get_rules[0]),
|
|
|
36ae71 |
a.get_rules[1], a.get_rules[2])
|
|
|
36ae71 |
diff --git a/src/firewall-offline-cmd b/src/firewall-offline-cmd
|
|
|
36ae71 |
index 112aa1c..97ee213 100755
|
|
|
36ae71 |
--- a/src/firewall-offline-cmd
|
|
|
36ae71 |
+++ b/src/firewall-offline-cmd
|
|
|
36ae71 |
@@ -33,7 +33,7 @@ import os
|
|
|
36ae71 |
from firewall.core.fw_test import Firewall_test
|
|
|
36ae71 |
from firewall.client import *
|
|
|
36ae71 |
from firewall.errors import *
|
|
|
36ae71 |
-from firewall.functions import joinArgs
|
|
|
36ae71 |
+from firewall.functions import joinArgs, splitArgs
|
|
|
36ae71 |
|
|
|
36ae71 |
# check for root user
|
|
|
36ae71 |
if os.getuid() != 0:
|
|
|
36ae71 |
@@ -495,7 +495,7 @@ parser_direct.add_argument("--remove-passthrough", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
parser_direct.add_argument("--query-passthrough", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", "<args>"))
|
|
|
36ae71 |
parser_direct.add_argument("--get-passthroughs", nargs=1,
|
|
|
36ae71 |
- metavar=("{ ipv4 | ipv6 | eb }", "<args>"))
|
|
|
36ae71 |
+ metavar=("{ ipv4 | ipv6 | eb }"))
|
|
|
36ae71 |
parser_direct.add_argument("--get-all-passthroughs", action="store_true")
|
|
|
36ae71 |
parser_direct.add_argument("--add-chain", nargs=3,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", "", "<chain>"))
|
|
|
36ae71 |
@@ -511,7 +511,7 @@ parser_direct.add_argument("--add-rule", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
parser_direct.add_argument("--remove-rule", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", " <chain> <priority> <args>"))
|
|
|
36ae71 |
parser_direct.add_argument("--remove-rules", nargs=3,
|
|
|
36ae71 |
- metavar=("{ ipv4 | ipv6 | eb }", " <chain> <args>"))
|
|
|
36ae71 |
+ metavar=("{ ipv4 | ipv6 | eb }", " <chain>"))
|
|
|
36ae71 |
parser_direct.add_argument("--query-rule", nargs=argparse.REMAINDER,
|
|
|
36ae71 |
metavar=("{ ipv4 | ipv6 | eb }", " <chain> <priority> <args>"))
|
|
|
36ae71 |
parser_direct.add_argument("--get-rules", nargs=3,
|
|
|
36ae71 |
@@ -521,7 +521,28 @@ parser_direct.add_argument("--get-all-rules", action="store_true")
|
|
|
36ae71 |
##############################################################################
|
|
|
36ae71 |
|
|
|
36ae71 |
if len(sys.argv) > 1:
|
|
|
36ae71 |
- a = parser.parse_args()
|
|
|
36ae71 |
+ i = -1
|
|
|
36ae71 |
+ args = sys.argv[1:]
|
|
|
36ae71 |
+ if '--add-passthrough' in args:
|
|
|
36ae71 |
+ i = args.index('--add-passthrough') + 1
|
|
|
36ae71 |
+ elif '--remove-passthrough' in args:
|
|
|
36ae71 |
+ i = args.index('--remove-passthrough') + 1
|
|
|
36ae71 |
+ elif '--query-passthrough' in args:
|
|
|
36ae71 |
+ i = args.index('--query-passthrough') + 1
|
|
|
36ae71 |
+ elif '--add-rule' in args:
|
|
|
36ae71 |
+ i = args.index('--add-rule') + 4
|
|
|
36ae71 |
+ elif '--remove-rule' in args:
|
|
|
36ae71 |
+ i = args.index('--remove-rule') + 4
|
|
|
36ae71 |
+ elif '--query-rule' in args:
|
|
|
36ae71 |
+ i = args.index('--query-rule') + 4
|
|
|
36ae71 |
+ # join <args> into one argument to prevent parser from parsing each iptables
|
|
|
36ae71 |
+ # option, because they can conflict with firewall-cmd options
|
|
|
36ae71 |
+ # # e.g. --delete (iptables) and --delete-* (firewall-cmd)
|
|
|
36ae71 |
+ if (i > -1) and (i < len(args) - 1):
|
|
|
36ae71 |
+ aux_args = args[:]
|
|
|
36ae71 |
+ args = aux_args[:i+1] # all but not <args>
|
|
|
36ae71 |
+ args.append(joinArgs(aux_args[i+1:])) # add <args> as one arg
|
|
|
36ae71 |
+ a = parser.parse_args(args)
|
|
|
36ae71 |
else:
|
|
|
36ae71 |
# migrate configuration from /etc/sysconfig/system-config-firewall
|
|
|
36ae71 |
args = read_sysconfig_args()
|
|
|
36ae71 |
@@ -826,19 +847,19 @@ try:
|
|
|
36ae71 |
if len (a.add_passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --direct --add-passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
__print(settings.add_passthrough(_check_ipv(a.add_passthrough[0]),
|
|
|
36ae71 |
- a.add_passthrough[1:]))
|
|
|
36ae71 |
+ splitArgs(a.add_passthrough[1])))
|
|
|
36ae71 |
|
|
|
36ae71 |
elif a.remove_passthrough:
|
|
|
36ae71 |
if len (a.remove_passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --direct --remove-passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
settings.remove_passthrough(_check_ipv(a.remove_passthrough[0]),
|
|
|
36ae71 |
- a.remove_passthrough[1:])
|
|
|
36ae71 |
+ splitArgs(a.remove_passthrough[1]))
|
|
|
36ae71 |
elif a.query_passthrough:
|
|
|
36ae71 |
if len (a.query_passthrough) < 2:
|
|
|
36ae71 |
__fail("usage: --direct --query-passthrough { ipv4 | ipv6 | eb } <args>")
|
|
|
36ae71 |
__print_query_result(
|
|
|
36ae71 |
settings.query_passthrough(_check_ipv(a.query_passthrough[0]),
|
|
|
36ae71 |
- a.query_passthrough[1:]))
|
|
|
36ae71 |
+ splitArgs(a.query_passthrough[1])))
|
|
|
36ae71 |
sys.exit(0)
|
|
|
36ae71 |
elif a.get_passthroughs:
|
|
|
36ae71 |
rules = settings.get_passthroughs(_check_ipv(a.get_passthroughs[0]))
|
|
|
36ae71 |
@@ -883,7 +904,7 @@ try:
|
|
|
36ae71 |
except ValueError:
|
|
|
36ae71 |
__fail("wrong priority\nusage: --direct --add-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
settings.add_rule(_check_ipv(a.add_rule[0]), a.add_rule[1],
|
|
|
36ae71 |
- a.add_rule[2], priority, a.add_rule[4:])
|
|
|
36ae71 |
+ a.add_rule[2], priority, splitArgs(a.add_rule[4]))
|
|
|
36ae71 |
elif a.remove_rule:
|
|
|
36ae71 |
if len (a.remove_rule) < 5:
|
|
|
36ae71 |
__fail("usage: --direct --remove-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
@@ -892,7 +913,7 @@ try:
|
|
|
36ae71 |
except ValueError:
|
|
|
36ae71 |
__fail("usage: --direct --remove-rule { ipv4 | ipv6 | eb } <chain> <priority> <args>")
|
|
|
36ae71 |
settings.remove_rule(_check_ipv(a.remove_rule[0]), a.remove_rule[1],
|
|
|
36ae71 |
- a.remove_rule[2], priority, a.remove_rule[4:])
|
|
|
36ae71 |
+ a.remove_rule[2], priority, splitArgs(a.remove_rule[4]))
|
|
|
36ae71 |
elif a.remove_rules:
|
|
|
36ae71 |
if len (a.remove_rules) < 3:
|
|
|
36ae71 |
__fail("usage: --direct --remove-rules { ipv4 | ipv6 | eb } <chain>")
|
|
|
36ae71 |
@@ -908,7 +929,7 @@ try:
|
|
|
36ae71 |
__print_query_result(
|
|
|
36ae71 |
settings.query_rule(_check_ipv(a.query_rule[0]),
|
|
|
36ae71 |
a.query_rule[1], a.query_rule[2],
|
|
|
36ae71 |
- priority, a.query_rule[4:]))
|
|
|
36ae71 |
+ priority, splitArgs(a.query_rule[4])))
|
|
|
36ae71 |
sys.exit(0)
|
|
|
36ae71 |
elif a.get_rules:
|
|
|
36ae71 |
rules = settings.get_rules(_check_ipv(a.get_rules[0]),
|
|
|
36ae71 |
diff --git a/src/firewall/functions.py b/src/firewall/functions.py
|
|
|
36ae71 |
index 6dd4240..ccbf583 100644
|
|
|
36ae71 |
--- a/src/firewall/functions.py
|
|
|
36ae71 |
+++ b/src/firewall/functions.py
|
|
|
36ae71 |
@@ -390,7 +390,7 @@ def joinArgs(args):
|
|
|
36ae71 |
return " ".join(pipes.quote(a) for a in args)
|
|
|
36ae71 |
|
|
|
36ae71 |
def splitArgs(string):
|
|
|
36ae71 |
- if PY2:
|
|
|
36ae71 |
+ if PY2 and isinstance(string, unicode):
|
|
|
36ae71 |
# Python2's shlex doesn't like unicode
|
|
|
36ae71 |
string = u2b(string)
|
|
|
36ae71 |
splits = shlex.split(string)
|
|
|
36ae71 |
--
|
|
|
36ae71 |
1.8.5.3
|
|
|
36ae71 |
|