Skip to content

Commit 22330fb

Browse files
fix(hakiri): fixed un-escaped regex for vcs link (#467)
* fix(hakiri): corrected unescaped model attribute * fix(hakiri): added html_safe to show proper output * fix(hakiri): added \A \z to regex * fix(questionnaire): fixed hakiri error with vcs link regex * fix(questionnaire): fixed houndci commplaint Co-authored-by: Chris Baudouin, Jr <[email protected]>
1 parent 64415c2 commit 22330fb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

app/models/questionnaire.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class Questionnaire < ApplicationRecord
4343

4444
validates :portfolio_url, url: { allow_blank: true }
4545
validates :vcs_url, url: { allow_blank: true }
46-
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"
47-
46+
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"
4847
strip_attributes
4948

5049
POSSIBLE_EXPERIENCES = {
@@ -135,7 +134,7 @@ def portfolio_url=(value)
135134
end
136135

137136
def vcs_url=(value)
138-
value = "http://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
137+
value = "https://" + value if !value.blank? && !value.include?("http://") && !value.include?("https://")
139138
super value
140139
end
141140

0 commit comments

Comments
 (0)