Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 14 additions & 23 deletions app/assets/js/vendors/magnific-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,29 +361,20 @@

// remove scrollbar, add margin e.t.c
$('html').css(windowStyles);

// add everything to DOM
var appendToEl = mfp.st.prependTo || $(document.body);

if (typeof mfp.st.prependTo === 'string') {
// Use document.querySelector to ensure the string is treated
try {
// 1. Attempt to query the element
var el = document.querySelector(mfp.st.prependTo);

// 2. Check if the element actually exists (querySelector returns null if not found)
if (el) {
appendToEl = $(el);
} else {
// Valid selector but element not found in DOM -> Fallback to body
appendToEl = $(document.body);
}
} catch (e) {
// Fallback to body if the selector is invalid
appendToEl = $(document.body);
}
}
mfp.bgOverlay.add(mfp.wrap).prependTo( appendToEl );

var appendToEl = mfp.st.prependTo;
// Default to body
var $appendToEl = $(document.body);

// Only allow DOM elements or jQuery objects
if (appendToEl instanceof HTMLElement) {
$appendToEl = $(appendToEl);

Check warning

Code scanning / CodeQL

Unsafe jQuery plugin Medium

Potential XSS vulnerability in the
'$.fn.magnificPopup' plugin
.

Copilot Autofix

AI 14 days ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

} else if (appendToEl && appendToEl.jquery) {
$appendToEl = appendToEl;
}

// Safe DOM insertion
mfp.bgOverlay.add(mfp.wrap).prependTo($appendToEl);

// Save last focused element
mfp._lastFocusedEl = document.activeElement;
Expand Down
Loading