Skip to content

Commit

Permalink
improve url checks
Browse files Browse the repository at this point in the history
  • Loading branch information
brondsem authored and Kenton Taylor committed Jun 17, 2024
1 parent d49f883 commit d73c6eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Allura/allura/lib/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/lib/widgets/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ class fields(ew_core.NameList):
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()

Expand Down

0 comments on commit d73c6eb

Please sign in to comment.