Skip to content

Commit 2d8504c

Browse files
committed
html to text: client side xss prevention
1 parent 7352ac5 commit 2d8504c

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

static/scripts/app.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ var posts = {
8888
$(posts_data).each(function(i, data){
8989
// Create empty post
9090
var post = $('#prepared .post_row').clone();
91-
post.find(".b_date").html(data.datetime);
9291

9392
// Update post data and apply scripts
9493
post.post_fill(data);
@@ -126,17 +125,17 @@ var cnt_funcs = {
126125
}
127126

128127
obj.attr("href", data.link);
129-
obj.find(".title").html(data.title);
130-
obj.find(".desc").html(data.desc);
131-
obj.find(".host").html(data.host);
128+
obj.find(".title").text(data.title);
129+
obj.find(".desc").text(data.desc);
130+
obj.find(".host").text(data.host);
132131

133132
return obj;
134133
},
135134
img_link: function(data){
136135
var obj = $("#prepared .b_imglink").clone();
137136
obj.attr("href", data.src);
138137
obj.find("img").attr("src", data.src);
139-
obj.find(".host").html(data.host);
138+
obj.find(".host").text(data.host);
140139

141140
return obj;
142141
},
@@ -338,7 +337,6 @@ var new_post = {
338337

339338
// Create empty post
340339
var post = $('#prepared .post_row').clone();
341-
post.find(".b_date").html(data.datetime);
342340

343341
// Update post data and apply scripts
344342
post.post_fill(data);
@@ -381,7 +379,7 @@ $.fn.error_msg = function(msg){
381379
err_msg.active = true;
382380
err_msg.obj = $("<div></div>");
383381
err_msg.obj.addClass("error");
384-
err_msg.obj.html(msg);
382+
err_msg.obj.text(msg);
385383

386384
var clear = $("<button></button>");
387385
clear.addClass("clear");
@@ -480,7 +478,7 @@ $.fn.apply_edit = function(data){
480478
};
481479

482480
// Set data and key listeners for text div
483-
//modal.find(".e_text").html(data.plain_text)
481+
//modal.find(".e_text").text(data.plain_text)
484482
modal.find(".e_text").val(data.plain_text)
485483
/*.keydown(function(e) {
486484
if(e.keyCode === 13){
@@ -643,6 +641,9 @@ $.fn.post_fill = function(data){
643641
location.hash = 'tag\='+tag;
644642
});
645643

644+
if(data.datetime)
645+
post.find(".b_date").text(data.datetime);
646+
646647
post.find(".b_date").attr("href", "#id="+data.id);
647648

648649
/*
@@ -681,9 +682,9 @@ $.fn.post_fill = function(data){
681682
});
682683
}
683684

684-
post.find(".b_feeling").html(data.feeling);
685-
post.find(".b_persons").html(data.persons);
686-
post.find(".b_location").html(data.location).click(function(){
685+
post.find(".b_feeling").text(data.feeling);
686+
post.find(".b_persons").text(data.persons);
687+
post.find(".b_location").text(data.location).click(function(){
687688
location.hash = 'loc\='+$(this).text();
688689
});
689690

@@ -869,7 +870,7 @@ $.fn.apply_post = function(){
869870
return ;
870871
}
871872

872-
post.find(".b_date").html(data.datetime);
873+
post.find(".b_date").text(data.datetime);
873874
modal.close();
874875
}
875876
});

0 commit comments

Comments
 (0)