Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-02-26 00:51:15 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-02-26 00:51:15 +0400
commit5e69ad2ceae8d3619775695b7fcab62a7a32377a (patch)
treeecb1092f6972fd66bf088b1ca3cf2f32dedd9aee /app/controllers/profiles_controller.rb
parentdb8baf2895f111652699c5b48d8cb2663eed6c3f (diff)
Sanitize user profile input
Diffstat (limited to 'app/controllers/profiles_controller.rb')
-rw-r--r--app/controllers/profiles_controller.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index 051a6664519..6fa114a4194 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -1,4 +1,6 @@
class ProfilesController < ApplicationController
+ include ActionView::Helpers::SanitizeHelper
+
before_filter :user
layout 'profile'
@@ -12,7 +14,7 @@ class ProfilesController < ApplicationController
end
def update
- if @user.update_attributes(params[:user])
+ if @user.update_attributes(user_attributes)
flash[:notice] = "Profile was successfully updated"
else
flash[:alert] = "Failed to update profile"
@@ -65,4 +67,17 @@ class ProfilesController < ApplicationController
def user
@user = current_user
end
+
+ def user_attributes
+ user_attributes = params[:user]
+
+ # Sanitize user input because we dont have strict
+ # validation for this fields
+ %w(name skype linkedin twitter bio).each do |attr|
+ value = user_attributes[attr]
+ user_attributes[attr] = sanitize(value) if value.present?
+ end
+
+ user_attributes
+ end
end