Patchwork mac: fix percent-encoding of non-utf-8 characters (issue4999)

login
register
mail settings
Submitter Matt Mackall
Date Dec. 13, 2015, 3:49 a.m.
Message ID <f403693d5f7c139df6c9.1449978550@ruin.waste.org>
Download mbox | patch
Permalink /patch/11995/
State Accepted
Commit c7129ed280b8a693fb2a69fb2371c064d553e4f4
Delegated to: Yuya Nishihara
Headers show

Comments

Matt Mackall - Dec. 13, 2015, 3:49 a.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1449977781 21600
#      Sat Dec 12 21:36:21 2015 -0600
# Node ID f403693d5f7c139df6c91f77104b89d24c988b2f
# Parent  944af8e2eb4cddf96ba5b8a96854528b40979715
mac: fix percent-encoding of non-utf-8 characters (issue4999)
Yuya Nishihara - Dec. 13, 2015, 6:45 a.m.
On Sat, 12 Dec 2015 21:49:10 -0600, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm@selenic.com>
> # Date 1449977781 21600
> #      Sat Dec 12 21:36:21 2015 -0600
> # Node ID f403693d5f7c139df6c91f77104b89d24c988b2f
> # Parent  944af8e2eb4cddf96ba5b8a96854528b40979715
> mac: fix percent-encoding of non-utf-8 characters (issue4999)
> 
> diff -r 944af8e2eb4c -r f403693d5f7c mercurial/posix.py
> --- a/mercurial/posix.py	Fri Dec 11 17:45:19 2015 -0600
> +++ b/mercurial/posix.py	Sat Dec 12 21:36:21 2015 -0600
> @@ -271,13 +271,13 @@
>              # OS X percent-encodes any bytes that aren't valid utf-8
>              s = ''
>              pos = 0
> -            l = len(s)
> +            l = len(path)
>              while pos < l:
>                  try:
>                      c = encoding.getutf8char(path, pos)
>                      pos += len(c)
>                  except ValueError:
> -                    c = '%%%%02X' % path[pos]
> +                    c = '%%%02X' % ord(path[pos])

Oops, looks good to me. Should I queue this or will you push it to the main
repo? It seems the clowncopter is dead right now.
Matt Mackall - Dec. 14, 2015, 8:06 p.m.
On Sun, 2015-12-13 at 15:45 +0900, Yuya Nishihara wrote:
> On Sat, 12 Dec 2015 21:49:10 -0600, Matt Mackall wrote:
> > # HG changeset patch
> > # User Matt Mackall <mpm@selenic.com>
> > # Date 1449977781 21600
> > #      Sat Dec 12 21:36:21 2015 -0600
> > # Node ID f403693d5f7c139df6c91f77104b89d24c988b2f
> > # Parent  944af8e2eb4cddf96ba5b8a96854528b40979715
> > mac: fix percent-encoding of non-utf-8 characters (issue4999)
> > 
> > diff -r 944af8e2eb4c -r f403693d5f7c mercurial/posix.py
> > --- a/mercurial/posix.py	Fri Dec 11 17:45:19 2015 -0600
> > +++ b/mercurial/posix.py	Sat Dec 12 21:36:21 2015 -0600
> > @@ -271,13 +271,13 @@
> >              # OS X percent-encodes any bytes that aren't valid
> > utf-8
> >              s = ''
> >              pos = 0
> > -            l = len(s)
> > +            l = len(path)
> >              while pos < l:
> >                  try:
> >                      c = encoding.getutf8char(path, pos)
> >                      pos += len(c)
> >                  except ValueError:
> > -                    c = '%%%%02X' % path[pos]
> > +                    c = '%%%02X' % ord(path[pos])
> 
> Oops, looks good to me. Should I queue this or will you push it to
> the main
> repo? It seems the clowncopter is dead right now.

I'll take care of it.

Patch

diff -r 944af8e2eb4c -r f403693d5f7c mercurial/posix.py
--- a/mercurial/posix.py	Fri Dec 11 17:45:19 2015 -0600
+++ b/mercurial/posix.py	Sat Dec 12 21:36:21 2015 -0600
@@ -271,13 +271,13 @@ 
             # OS X percent-encodes any bytes that aren't valid utf-8
             s = ''
             pos = 0
-            l = len(s)
+            l = len(path)
             while pos < l:
                 try:
                     c = encoding.getutf8char(path, pos)
                     pos += len(c)
                 except ValueError:
-                    c = '%%%%02X' % path[pos]
+                    c = '%%%02X' % ord(path[pos])
                     pos += 1
                 s += c