Change away from the Windows directory separator for the escape char

This commit is contained in:
Jean-Paul Calderone 2019-02-26 19:06:35 -05:00
parent 25a62001dd
commit d203fde9f6
2 changed files with 9 additions and 4 deletions

View File

@ -206,7 +206,7 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, RunBinTahoeMixin):
@inlineCallbacks
def test_escape_in_eliot_destination(self):
out, err, rc_or_sig = yield self.run_bintahoe([
"--eliot-destination=file:\\foo",
"--eliot-destination=file:@foo",
])
self.assertEqual(1, rc_or_sig)
self.assertIn("Unsupported escape character", out)

View File

@ -432,10 +432,15 @@ class _DestinationParser(object):
)
def _parse_file(self, kind, arg_text):
# Reserve the possibility of an escape character in the future.
if u"\\" in arg_text:
# Reserve the possibility of an escape character in the future. \ is
# the standard choice but it's the path separator on Windows which
# pretty much ruins it in this context. Most other symbols already
# have some shell-assigned meaning which makes them treacherous to use
# in a CLI interface. Eliminating all such dangerous symbols leaves
# approximately @.
if u"@" in arg_text:
raise ValueError(
u"Unsupported escape character (\\) in destination text ({!r}).".format(arg_text),
u"Unsupported escape character (@) in destination text ({!r}).".format(arg_text),
)
arg_list = arg_text.split(u":")
path_name = arg_list.pop(0)