VRFS-1971 escape HTML before saving / unescape before rendering

This commit is contained in:
Brian Smith 2014-08-07 00:50:10 -04:00
parent 199ef029bc
commit d40b29a947
7 changed files with 8 additions and 6 deletions

View File

@ -77,6 +77,7 @@ gem 'rest_client'
gem 'iso-639'
gem 'language_list'
gem 'rubyzip'
gem 'htmlentities'
group :development, :test do
gem 'rspec-rails', '2.14.2'

View File

@ -71,7 +71,7 @@
user_id: userId,
hoverAction: musician ? "musician" : "fan",
name: userName,
comment: comment,
comment: context._.unescape(comment),
timeago: timeago
};

View File

@ -39,7 +39,7 @@
user_id: userId,
hoverAction: "musician",
name: userName,
comment: comment,
comment: context._.unescape(comment),
timeago: timeago
});

View File

@ -39,7 +39,7 @@
user_id: userId,
hoverAction: musician ? "musician" : "fan",
name: userName,
comment: comment,
comment: context._.unescape(comment),
timeago: timeago
});

View File

@ -1,6 +1,7 @@
class ApiController < ApplicationController
@@log = Logging.logger[ApiController]
@@html_encoder = HTMLEntities.new
# define common error handlers
rescue_from 'JamRuby::StateError' do |exception|

View File

@ -469,7 +469,7 @@ class ApiMusicSessionsController < ApiController
comment = MusicSessionComment.new
comment.music_session_id = params[:id]
comment.creator_id = params[:user_id]
comment.comment = params[:comment]
comment.comment = @@html_encoder.encode(params[:comment])
comment.ip_address = request.remote_ip
comment.save
@ -496,7 +496,7 @@ class ApiMusicSessionsController < ApiController
comment = SessionInfoComment.new
comment.music_session_id = params[:id]
comment.creator_id = current_user.id
comment.comment = params[:comment]
comment.comment = @@html_encoder.encode(params[:comment])
comment.save
if comment.errors.any?

View File

@ -108,7 +108,7 @@ class ApiRecordingsController < ApiController
comment = RecordingComment.new
comment.recording_id = params[:id]
comment.creator_id = params[:user_id]
comment.comment = params[:comment]
comment.comment = @@html_encoder.encode(params[:comment])
comment.ip_address = request.remote_ip
comment.save