Skip to content

Commit

Permalink
accept only avatar_url beginning with //
Browse files Browse the repository at this point in the history
Signed-off-by: Benoît Sibaud <oumph@linuxfr.org>
  • Loading branch information
Oumph authored and nono committed Sep 2, 2012
1 parent 5fe67a3 commit 04c8198
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def custom_avatar_url=(url)
url
end

before_validation :validate_url
def validate_url
return if custom_avatar_url.blank?
return if custom_avatar_url.starts_with?("//")
errors.add(:url, "Adresse de téléchargement d'avatar non valide")
end

def avatar_url
if avatar.present?
url = avatar.url
Expand Down

0 comments on commit 04c8198

Please sign in to comment.