This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 1f21d4d43acb26029f66518199e4e91ee063dfda
Author: Dave Brondsema <[email protected]>
AuthorDate: Tue May 7 11:56:38 2024 -0400

    rename class
---
 Allura/allura/lib/helpers.py                   | 4 ++--
 Allura/allura/lib/validators.py                | 5 +++--
 ForgeImporters/forgeimporters/trac/__init__.py | 2 +-
 ForgeSVN/forgesvn/widgets.py                   | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 0746639f2..c6fc9fbae 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -1051,7 +1051,7 @@ class NoInternalHTTPSHandler(urllib.request.HTTPSHandler):
     def https_open(self, req):
         if not asbool(tg.config.get('urlopen_allow_internal_hostnames', 
'false')):
             # check on every open, covers redirects
-            validators.URLIsPrivate().to_python(req.full_url, None)
+            validators.NonPrivateUrl().to_python(req.full_url, None)
         return super().https_open(req)
 
 class UseKnownIPHTTPConnection(http.client.HTTPConnection):
@@ -1069,7 +1069,7 @@ class NotInternalHTTPHandler(urllib.request.HTTPHandler):
     def http_open(self, req):
         if not asbool(tg.config.get('urlopen_allow_internal_hostnames', 
'false')):
             # check on every open, covers redirects
-            ipValidator = validators.URLIsPrivate()
+            ipValidator = validators.NonPrivateUrl()
             ipValidator.to_python(req.full_url, None)
             # and force the open to use the known IP
             return self.do_open(UseKnownIPHTTPConnection, req, 
known_ip_to_use=str(ipValidator.ip))
diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index 8b30d2989..b43f55e5f 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -48,8 +48,8 @@ class URL(fev.URL):
     ''', re.I | re.VERBOSE)
 
 
-class URLIsPrivate(URL):
-
+class NonPrivateUrl(URL):
+    # prevents private IPs
     def _convert_to_python(self, value, state):
         value = super()._convert_to_python(value, state)
         url_components = urlsplit(value)
@@ -65,6 +65,7 @@ class URLIsPrivate(URL):
 
 
 class NonHttpUrl(URL):
+    # allows other schemes like svn:// since fev.URL only does http(s)
     messages = {
         'noScheme': 'You must start your URL with a scheme',
     }
diff --git a/ForgeImporters/forgeimporters/trac/__init__.py 
b/ForgeImporters/forgeimporters/trac/__init__.py
index 126466651..fa3ddd371 100644
--- a/ForgeImporters/forgeimporters/trac/__init__.py
+++ b/ForgeImporters/forgeimporters/trac/__init__.py
@@ -21,7 +21,7 @@ import requests
 from allura.lib import validators
 
 
-class TracURLValidator(validators.URLIsPrivate):
+class TracURLValidator(validators.NonPrivateUrl):
     not_empty = True
     messages = {
         'unavailable': 'This project is unavailable for import'
diff --git a/ForgeSVN/forgesvn/widgets.py b/ForgeSVN/forgesvn/widgets.py
index abf2044e6..eb938411a 100644
--- a/ForgeSVN/forgesvn/widgets.py
+++ b/ForgeSVN/forgesvn/widgets.py
@@ -25,7 +25,7 @@ from allura.lib import validators
 from allura.lib.widgets.forms import ForgeForm
 
 
-class ValidateSvnUrl(validators.URLIsPrivate):
+class ValidateSvnUrl(validators.NonPrivateUrl):
     url_re = re.compile(r'''
         ^(http|https|svn)://
         (?:[%:\w]*@)?                              # authenticator

Reply via email to