Permalink
Browse files

Escape github repo descriptions, as they may contain HTML.

  • Loading branch information...
1 parent c814560 commit bcdc904843d09ab686a1e380019bfdf2f145a665 @rixth rixth committed Jan 3, 2013
Showing with 4 additions and 1 deletion.
  1. +4 −1 .themes/classic/source/javascripts/github.js
@@ -1,9 +1,12 @@
var github = (function(){
+ function escapeHtml(str) {
+ return $('<div/>').text(str).html();
+ }
function render(target, repos){
var i = 0, fragment = '', t = $(target)[0];
for(i = 0; i < repos.length; i++) {
- fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+(repos[i].description||'')+'</p></li>';
+ fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+escapeHtml(repos[i].description||'')+'</p></li>';
}
t.innerHTML = fragment;
}

0 comments on commit bcdc904

Please sign in to comment.