Patchwork [v3] py3: properly reject non-encoded strings given to hgweb

login
register
mail settings
Submitter Ludovic Chabant
Date April 28, 2019, 4:22 a.m.
Message ID <6805ebb0f1f6a7f34a74.1556425373@devahi>
Download mbox | patch
Permalink /patch/39852/
State Accepted
Headers show

Comments

Ludovic Chabant - April 28, 2019, 4:22 a.m.
# HG changeset patch
# User Ludovic Chabant <ludovic@chabant.com>
# Date 1555683992 0
#      Fri Apr 19 14:26:32 2019 +0000
# Branch stable
# Node ID 6805ebb0f1f6a7f34a74732ee6f6ec14e8824e42
# Parent  3611368a1af3037427eb59635c7dad8dab67c606
py3: properly reject non-encoded strings given to hgweb
Yuya Nishihara - April 28, 2019, 8:10 a.m.
On Sun, 28 Apr 2019 04:22:53 +0000, Ludovic Chabant wrote:
> # HG changeset patch
> # User Ludovic Chabant <ludovic@chabant.com>
> # Date 1555683992 0
> #      Fri Apr 19 14:26:32 2019 +0000
> # Branch stable
> # Node ID 6805ebb0f1f6a7f34a74732ee6f6ec14e8824e42
> # Parent  3611368a1af3037427eb59635c7dad8dab67c606
> py3: properly reject non-encoded strings given to hgweb

Queued, thanks.

> diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py
> --- a/mercurial/hgweb/__init__.py
> +++ b/mercurial/hgweb/__init__.py
> @@ -13,6 +13,7 @@
>  from ..i18n import _
>  
>  from .. import (
> +    encoding,

Dropped this.

Patch

diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py
--- a/mercurial/hgweb/__init__.py
+++ b/mercurial/hgweb/__init__.py
@@ -13,6 +13,7 @@ 
 from ..i18n import _
 
 from .. import (
+    encoding,
     error,
     pycompat,
 )
@@ -38,6 +39,9 @@ 
     - list of virtual:real tuples (multi-repo view)
     '''
 
+    if isinstance(config, pycompat.unicode):
+        raise error.ProgrammingError(
+            'Mercurial only supports encoded strings: %r' % config)
     if ((isinstance(config, bytes) and not os.path.isdir(config)) or
         isinstance(config, dict) or isinstance(config, list)):
         # create a multi-dir interface