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


The following commit(s) were added to refs/heads/master by this push:
     new d73c6ebed improve url checks
d73c6ebed is described below

commit d73c6ebedb27e2ccfd9adba042e20c30207479c5
Author: Dave Brondsema <[email protected]>
AuthorDate: Fri Jun 14 10:53:31 2024 -0400

    improve url checks
---
 Allura/allura/lib/validators.py    | 8 ++++----
 Allura/allura/lib/widgets/forms.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
index b43f55e5f..c2e5374d1 100644
--- a/Allura/allura/lib/validators.py
+++ b/Allura/allura/lib/validators.py
@@ -509,7 +509,7 @@ class LinkedinValidator(fev.FancyValidator):
     def _convert_to_python(self, value, state):
         if value.startswith('@') and not re.match(FEDIVERSE_REGEX, value):
             value = f'https://linkedin.com/in/{value.replace("@", "")}/'
-        elif 'linkedin.com' not in value:
+        elif not value.startswith('http') or 'linkedin.com' not in value:
             raise fe.Invalid('Invalid Linkedin address', value, state)
         return value
 
@@ -518,7 +518,7 @@ class TwitterValidator(fev.FancyValidator):
     def _convert_to_python(self, value, state):
         if value.startswith('@') and not re.match(FEDIVERSE_REGEX, value):
             value = f'https://twitter.com/{value.replace("@", "")}'
-        elif 'twitter.com' not in value:
+        elif not value.startswith('http') or 'twitter.com' not in value:
             raise fe.Invalid('Invalid Twitter address', value, state)
         return value
 
@@ -527,7 +527,7 @@ class InstagramValidator(fev.FancyValidator):
     def _convert_to_python(self, value, state):
         if value.startswith('@') and not re.match(FEDIVERSE_REGEX, value):
             value = f'https://instagram.com/{value.replace("@", "")}'
-        elif 'instagram.com' not in value:
+        elif not value.startswith('http') or 'instagram.com' not in value:
             raise fe.Invalid('Invalid Instagram address', value, state)
         return value
 
@@ -536,7 +536,7 @@ class FacebookValidator(fev.FancyValidator):
     def _convert_to_python(self, value, state):
         if value.startswith('@') and not re.match(FEDIVERSE_REGEX, value):
             value = f'https://facebook.com/{value.replace("@", "")}'
-        elif 'facebook.com' not in value:
+        elif not value.startswith('http') or 'facebook.com' not in value:
             raise fe.Invalid('Invalid Facebook address', value, state)
         return value
 
diff --git a/Allura/allura/lib/widgets/forms.py 
b/Allura/allura/lib/widgets/forms.py
index 1c737ba5d..d3c8ddff8 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -836,7 +836,7 @@ class NeighborhoodOverviewForm(ForgeForm):
             validator=V.JsonValidator(if_empty=''))
         icon = ew.FileField(attrs={'accept': 'image/*'})
         tracking_id = ew.TextField(attrs=(dict(placeholder='UA-123456-0', 
pattern='UA-[0-9]+-[0-9]+')))
-        project_list_url = ew.TextField()
+        project_list_url = ew.TextField(validator=fev.URL(), 
attrs=dict(type='url'))
         anchored_tools = ffw.AutoResizeTextarea()
         prohibited_tools = ffw.AutoResizeTextarea()
 

Reply via email to