From patchwork Mon Jan 8 13:36:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5,of,7] revsetlang: fix quoting of %ls string From: Yuya Nishihara X-Patchwork-Id: 26614 Message-Id: <67abdcafc543c3f08adc.1515418588@mimosa> To: mercurial-devel@mercurial-scm.org Date: Mon, 08 Jan 2018 22:36:28 +0900 # HG changeset patch # User Yuya Nishihara # Date 1491036716 -32400 # Sat Apr 01 17:51:56 2017 +0900 # Node ID 67abdcafc543c3f08adc0d1e4041703e708d28e1 # Parent ecabe925e5997399ca48624b73bbde33a6e9c1c5 revsetlang: fix quoting of %ls string Before, "'" wasn't escaped appropriately. This also changes the separator '\0' to '\\0', but that's okay as a string token is unescaped. diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py --- a/mercurial/revsetlang.py +++ b/mercurial/revsetlang.py @@ -585,7 +585,9 @@ def formatspec(expr, *args): >>> formatspec(b'branch(%b)', b) "branch('default')" >>> formatspec(b'root(%ls)', [b'a', b'b', b'c', b'd']) - "root(_list('a\\x00b\\x00c\\x00d'))" + "root(_list('a\\\\x00b\\\\x00c\\\\x00d'))" + >>> formatspec('%ls', ['a', "'"]) + "_list('a\\\\x00\\\\'')" ''' def argtype(c, arg): @@ -614,7 +616,7 @@ def formatspec(expr, *args): elif t == 'd': return "_intlist('%s')" % "\0".join('%d' % int(a) for a in s) elif t == 's': - return "_list('%s')" % "\0".join(s) + return "_list(%s)" % _quote("\0".join(s)) elif t == 'n': return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s) elif t == 'b':