mirror of
https://github.com/A-Star100/simpliplay-desktop.git
synced 2025-09-17 22:29:38 +00:00
Update renderer.js
This commit is contained in:
parent
0304d68187
commit
3b6be1434b
@ -1,8 +1,3 @@
|
||||
// Listen for media file URL from main process
|
||||
window.electron.receive("play-media", (fileURL) => {
|
||||
loadMedia(fileURL);
|
||||
});
|
||||
|
||||
function loadMedia(fileURL) {
|
||||
dialogOverlay.style.display = 'none';
|
||||
const mediaElement = document.getElementById("mediaPlayer");
|
||||
@ -18,3 +13,23 @@ function loadMedia(fileURL) {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Validate media URL
|
||||
function isSafeURL(fileURL) {
|
||||
try {
|
||||
const url = new URL(fileURL);
|
||||
return url.protocol === "file:";
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ✅ Listen for "play-media" event from main process securely
|
||||
window.electron.receive("play-media", (fileURL) => {
|
||||
if (isSafeURL(fileURL)) {
|
||||
loadMedia(fileURL);
|
||||
} else {
|
||||
console.warn("Blocked unsafe media URL:", fileURL);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user