Skip to content

fix(hakiri): fixed un-escaped regex for vcs link #467

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

Merged
merged 9 commits into from
Dec 18, 2020
5 changes: 2 additions & 3 deletions app/models/questionnaire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class Questionnaire < ApplicationRecord

validates :portfolio_url, url: { allow_blank: true }
validates :vcs_url, url: { allow_blank: true }
validates_format_of :vcs_url, with: %r{((github.com\/\w+\/?)|(gitlab.com\/\w+\/?)|(bitbucket.org\/\w+\/?))}, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url"

validates_format_of :vcs_url, with: %r{\A(((https?:\/\/)?(www\.)?github\.com\/\w+\/?)|((https?:\/\/)?(www\.)?gitlab\.com\/\w+\/?)|((https?:\/\/)?(www\.)?bitbucket\.org\/\w+\/?))\z}, allow_blank: true, message: "Must be a GitHub, GitLab or Bitbucket url"
strip_attributes

POSSIBLE_EXPERIENCES = {
Expand Down Expand Up @@ -135,7 +134,7 @@ def portfolio_url=(value)
end

def vcs_url=(value)
value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
value = "https://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
super value
end

Expand Down