Skip to content

Commit 1a50dcc

Browse files
committed
Fixes embed templates; escapes message content before passing it to plugins
Signed-off-by: Akash Manohar J <akash@akash.im>
1 parent a5ef905 commit 1a50dcc

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

app/assets/javascripts/backbone/plugins/image_embed.js.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class Kandan.Plugins.ImageEmbed
44

55
template: _.template '''
66
<div class="image-preview">
7-
<a target="_blank" href="<%= image_url %>">
8-
<img class="image-embed" src="<%= image_url %>" height="200" width="200" />
7+
<a target="_blank" href="<%= imageUrl %>">
8+
<img class="image-embed" src="<%= imageUrl %>" height="200" width="200" />
99
</a>
1010
<div class="name"><%= subtitle %></div>
1111
</div>

app/assets/javascripts/backbone/plugins/youtube_embed.js.coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class Kandan.Plugins.YouTubeEmbed
66

77
template: _.template '''
88
<div class="youtube-preview">
9-
<a target="_blank" class="youtube-preview-link" href="<%= video_url %>">
10-
<img class="youtube-preview-image" src="<%= thumb_url %>" />
9+
<a target="_blank" class="youtube-preview-link" href="<%= videoUrl %>">
10+
<img class="youtube-preview-image" src="<%= thumbUrl %>" />
1111
</a>
1212
<div class="name"><%= subtitle %></div>
1313
</div>
@@ -27,7 +27,7 @@ class Kandan.Plugins.YouTubeEmbed
2727
videoUrl = message.content.split(" ")[0]
2828

2929
videoId = message.content.match(@options.idRegex)[1]
30-
thumbUrl = "http://img.youtube.com/vi/#{ video_id }/0.jpg"
30+
thumbUrl = "http://img.youtube.com/vi/#{ videoId }/0.jpg"
3131

3232
subtitle = null
3333
subtitle = "Youtube: #{comment}" if comment? and comment.length > 0

app/assets/javascripts/backbone/views/show_activity.js.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ class Kandan.Views.ShowActivity extends Backbone.View
55

66
render: ()->
77
activity = @options.activity.toJSON()
8-
console.log("Rendering activity:")
8+
activity.content = _.escape(activity.content)
99
if activity.action != "message"
1010
@compiledTemplate = JST['user_notification']({activity: activity})
1111
else
1212
modifiedMessage = Kandan.Modifiers.process(activity, @options.state)
1313
if modifiedMessage != false
1414
@compiledTemplate = modifiedMessage
1515
else
16-
@compiledTemplate = Kandan.Helpers.Activities.buildFromMessageTemplate $.extend(activity, {content: _.escape(activity.content)})
16+
@compiledTemplate = Kandan.Helpers.Activities.buildFromMessageTemplate activity
1717

1818
$(@el).data("activity-id", activity.id)
1919
$(@el).attr("id", "activity-#{activity.id}")

0 commit comments

Comments
 (0)