Submitter | phabricator |
---|---|
Date | Oct. 8, 2019, 4:43 a.m. |
Message ID | <differential-rev-PHID-DREV-74xv7ttpvdbhscxid4yl-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/42092/ |
State | Superseded |
Headers | show |
Comments
marmoute added inline comments. INLINE COMMENTS > pycompat.py:343 > + s = shlex.quote(s) > + return s.encode('latin-1') > + It might be a silly questions, but why are we going through `latin-1` instead of `utf-8` or any other crazy encoding ? REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7020/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7020 To: indygreg, #hg-reviewers Cc: marmoute, mercurial-devel
indygreg added inline comments. INLINE COMMENTS > marmoute wrote in pycompat.py:343 > It might be a silly questions, but why are we going through `latin-1` instead of `utf-8` or any other crazy encoding ? Because the underlying string is likely raw bytes and `latin-1` will preserve those code points. i.e. we don't care what the encoding is: just that we can pass `str` to `shlex.quote`. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7020/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7020 To: indygreg, #hg-reviewers Cc: marmoute, mercurial-devel
See https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-October/134352.html
yuja added a comment. See https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-October/134352.html REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7020/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7020 To: indygreg, #hg-reviewers Cc: yuja, marmoute, mercurial-devel
indygreg added a comment. indygreg abandoned this revision. Yuya's patch fixed the test failure and is a better solution. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7020/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7020 To: indygreg, #hg-reviewers Cc: yuja, marmoute, mercurial-devel
Patch
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -337,7 +337,11 @@ ret = shlex.split(s.decode('latin-1'), comments, posix) return [a.encode('latin-1') for a in ret] - shlexquote = shlex.quote + def shlexquote(s): + s = s.decode('latin-1') + s = shlex.quote(s) + return s.encode('latin-1') + iteritems = lambda x: x.items() itervalues = lambda x: x.values()