Skip to content

Commit

Permalink
escape script tag
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspark committed Apr 30, 2018
1 parent afefcb9 commit d8e3b85
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions embed/js/crapcha.js
Expand Up @@ -106,6 +106,7 @@ var crapcha = {
captcha: $captcha.html(),
attempt: crapcha.attempt,
timestamp: firebase.database.ServerValue.TIMESTAMP
}, function(error) {
});
}

Expand Down
2 changes: 1 addition & 1 deletion embed/js/crapcha.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion index.html
Expand Up @@ -68,8 +68,9 @@ <h2>Recent CRAPCHAs</h2>

for (var i in snapshot.val()) {
var time = new Date(data[i].timestamp);
var captcha = data[i].captcha.replace(/<script ?/g, '&lt;script');

html = '<div class="crapcha"><div class="code">' + data[i].captcha + '</div><div class="recent">' + escapeHTML(data[i].attempt) + '</div><a href="./show/#' + i + '" class="time">' + time + '</a></div>' + html;
html = '<div class="crapcha"><div class="code">' + captcha + '</div><div class="recent">' + escapeHTML(data[i].attempt) + '</div><a href="./show/#' + i + '" class="time">' + time + '</a></div>' + html;
}

$('#recent').html(html);
Expand Down
3 changes: 2 additions & 1 deletion show/index.html
Expand Up @@ -65,8 +65,9 @@ <h2 style="margin: 4px 0;">Completely Ridiculous And Phony Captcha that Hassles
var data = snapshot.val();

var time = new Date(data.timestamp);
var captcha = data.captcha.replace(/<script ?/g, '&lt;script');

html = '<div class="crapcha"><div class="code">' + data.captcha + '</div><div class="recent">' + escapeHTML(data.attempt) + '</div><a href="./#' + id + '" class="time">' + time + '</a></div>';
html = '<div class="crapcha"><div class="code">' + captcha + '</div><div class="recent">' + escapeHTML(data.attempt) + '</div><a href="./#' + id + '" class="time">' + time + '</a></div>';

$('#recent').html(html);
});
Expand Down

0 comments on commit d8e3b85

Please sign in to comment.