Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Repository URLs #2446

Merged
merged 3 commits into from Mar 9, 2022
Merged

Conversation

mathjazz
Copy link
Collaborator

@mathjazz mathjazz commented Mar 8, 2022

We should validate Repository URLs before they are stored into the DB.

The repository_url_validator() has been tested with all Repository URLs on pontoon.mozilla.org. It supports all HTTP(S), FTP(S), SSH and SVN+SSH URLs, as well as Git SCP-like SSH URL.

@mathjazz mathjazz requested a review from eemeli March 8, 2022 21:23
Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SCP-like pattern is a bit too complex, otherwise looks fine.

pontoon/base/models.py Outdated Show resolved Hide resolved
mathjazz and others added 2 commits March 9, 2022 08:21
Co-authored-by: Eemeli Aro <eemeli@gmail.com>
@mathjazz mathjazz merged commit 6121e77 into mozilla:master Mar 9, 2022
@mathjazz mathjazz deleted the validate-repository-url branch March 9, 2022 07:51
eemeli pushed a commit that referenced this pull request Mar 15, 2022
@eudaldv
Copy link

eudaldv commented Oct 18, 2022

The pattern doesn't take into account dashes on the URL format.
Suggestion:
git@(((?!\-))(xn\-\-)?[a-z0-9\-_]{0,61}[a-z0-9]{1,1}\.)*(xn\-\-)?([a-z0-9\-]{1,61}|[a-z0-9\-]{1,30})\.[a-z]{2,}[/:][\w-]+/[\w-]+(.git)?/?

Best regards,
Eudald

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants