scrollToLinkedComment: Check for valid ObjectID before passing to jQuery

This commit is contained in:
Sybren A. Stüvel 2018-01-05 15:08:00 +01:00
parent 8f6966978f
commit d240a979ba

View File

@ -92,7 +92,9 @@ script.
// If there's a comment link in the URL, scroll there
function scrollToLinkedComment() {
var scrollToId = location.hash;
if (scrollToId.length <= 1) return;
// Check that it's a valid ObjectID before passing it to jQuery.
if (!/^[a-fA-F0-9]{24}$/.test(scrollToId)) return;
$(scrollToId)
.addClass('comment-linked')