diff mercurial/sslutil.py @ 38475:67dc32d4e790

cleanup: migrate from re.escape to stringutil.reescape This has consistent behavior on Python 2.7, 3.6, and 3.7 and has the benefit of probably being a little faster. Test output changes are largely because / used to be pointlessly escaped. Differential Revision: https://phab.mercurial-scm.org/D3842
author Augie Fackler <augie@google.com>
date Tue, 26 Jun 2018 10:36:23 -0400
parents 51a2f8d199c7
children 0d226b2139df
line wrap: on
line diff
--- a/mercurial/sslutil.py	Tue Jun 26 10:33:52 2018 -0400
+++ b/mercurial/sslutil.py	Tue Jun 26 10:36:23 2018 -0400
@@ -618,14 +618,14 @@
         # The client SHOULD NOT attempt to match a presented identifier
         # where the wildcard character is embedded within an A-label or
         # U-label of an internationalized domain name.
-        pats.append(re.escape(leftmost))
+        pats.append(stringutil.reescape(leftmost))
     else:
         # Otherwise, '*' matches any dotless string, e.g. www*
-        pats.append(re.escape(leftmost).replace(br'\*', '[^.]*'))
+        pats.append(stringutil.reescape(leftmost).replace(br'\*', '[^.]*'))
 
     # add the remaining fragments, ignore any wildcards
     for frag in remainder:
-        pats.append(re.escape(frag))
+        pats.append(stringutil.reescape(frag))
 
     pat = re.compile(br'\A' + br'\.'.join(pats) + br'\Z', re.IGNORECASE)
     return pat.match(hostname) is not None