Patchwork D2260: py3: add b'' to make sure regex pattern are bytes in hgweb/webutil.py

login
register
mail settings
Submitter phabricator
Date Feb. 14, 2018, 1:42 p.m.
Message ID <fdc59f15e9225da3fab32256a6a467a3@localhost.localdomain>
Download mbox | patch
Permalink /patch/27917/
State Not Applicable
Headers show

Comments

phabricator - Feb. 14, 2018, 1:42 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG44a519ec5077: py3: add b&#039;&#039; to make sure regex pattern are bytes in hgweb/webutil.py (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2260?vs=5700&id=5715

REVISION DETAIL
  https://phab.mercurial-scm.org/D2260

AFFECTED FILES
  mercurial/hgweb/webutil.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -626,15 +626,15 @@ 
         # delimiters. the replace format and flags are optional, but
         # delimiters are required.
         match = re.match(
-            r'^s%s(.+)(?:(?<=\\\\)|(?<!\\))%s(.*)%s([ilmsux])*$'
+            br'^s%s(.+)(?:(?<=\\\\)|(?<!\\))%s(.*)%s([ilmsux])*$'
             % (delim, delim, delim), pattern)
         if not match:
             repo.ui.warn(_("websub: invalid pattern for %s: %s\n")
                               % (key, pattern))
             continue
 
         # we need to unescape the delimiter for regexp and format
-        delim_re = re.compile(r'(?<!\\)\\%s' % delim)
+        delim_re = re.compile(br'(?<!\\)\\%s' % delim)
         regexp = delim_re.sub(unesc, match.group(1))
         format = delim_re.sub(unesc, match.group(2))