[go: up one dir, main page]

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

Add validations to URL attribute on Link model #2

Merged
merged 3 commits into from
Mar 20, 2015
Merged

Add validations to URL attribute on Link model #2

merged 3 commits into from
Mar 20, 2015

Conversation

jobertabma
Copy link
Contributor

Minor improvement to enforce only HTTP and HTTPS URLs can be entered. The list of allowed protocols can be easily extended if necessary in the Link model.

class Link < ActiveRecord::Base
validates :shortlink, presence: true, uniqueness: true
validates :url, presence: true
validates :url, presence: true, format: { with: URI::regexp(%w(http https)) }

Choose a reason for hiding this comment

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

Make sure this doesn't leave a vulnerability where you can do payloads like javascript:alert(1) http:// to circumvent this validation.

ebrynne added a commit that referenced this pull request Mar 20, 2015
Add validations to URL attribute on Link model
@ebrynne ebrynne merged commit 42598ec into ebrynne:master Mar 20, 2015
@hugofloss hugofloss mentioned this pull request Mar 23, 2015
ebrynne pushed a commit that referenced this pull request Jan 26, 2018
Update Rails and fix security issue
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.

3 participants