Skip to content
Snippets Groups Projects
Commit 15a971fd authored by Guilherme Gazzo's avatar Guilherme Gazzo
Browse files

resolved XSS in image preview

parent 323c7b47
No related branches found
No related tags found
No related merge requests found
......@@ -2,12 +2,12 @@ import PhotoSwipe from 'photoswipe';
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default';
import 'photoswipe/dist/photoswipe.css';
const escapeHTML = (html) => html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
Meteor.startup(() => {
const initGallery = (selector, items, options) => {
const gallery = new PhotoSwipe(selector, PhotoSwipeUI_Default, items, options);
gallery.init();
};
const getItems = (selector, imageSrc) => {
const results = {
index: 0,
......@@ -44,7 +44,7 @@ Meteor.startup(() => {
galleryOptions.index = images.index;
galleryOptions.addCaptionHTMLFn = function(item, captionEl) {
captionEl.children[0].innerHTML = `${ item.title }<br/><small>${ item.description }</small> `;
captionEl.children[0].innerHTML = `${ escapeHTML(item.title) }<br/><small>${ escapeHTML(item.description) }</small> `;
return true;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment