mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-26 15:12:47 -05:00
Require user-supplied URLs to be http protocol
This commit is contained in:
@@ -2,6 +2,7 @@ import fs from 'fs'
|
||||
import yargs from 'yargs'
|
||||
import { app, shell, session, BrowserWindow } from 'electron'
|
||||
|
||||
import { ensureValidURL } from '../util'
|
||||
import { pollPublicData, pollSpreadsheetData, StreamIDGenerator } from './data'
|
||||
import StreamWindow from './StreamWindow'
|
||||
import initWebServer from './server'
|
||||
@@ -79,6 +80,7 @@ async function main() {
|
||||
} else if (msg.type === 'reload-view') {
|
||||
streamWindow.reloadView(msg.viewIdx)
|
||||
} else if (msg.type === 'browse') {
|
||||
ensureValidURL(msg.url)
|
||||
if (!browseWindow || browseWindow.isDestroyed()) {
|
||||
browseWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import isEqual from 'lodash/isEqual'
|
||||
import { Machine, assign } from 'xstate'
|
||||
|
||||
import { ensureValidURL } from '../util'
|
||||
|
||||
const viewStateMachine = Machine(
|
||||
{
|
||||
id: 'view',
|
||||
@@ -116,6 +118,7 @@ const viewStateMachine = Machine(
|
||||
services: {
|
||||
loadPage: async (context, event) => {
|
||||
const { content, view } = context
|
||||
ensureValidURL(content.url)
|
||||
const wc = view.webContents
|
||||
wc.audioMuted = true
|
||||
await wc.loadURL(content.url)
|
||||
|
||||
6
src/util.js
Normal file
6
src/util.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export function ensureValidURL(urlStr) {
|
||||
const url = new URL(urlStr)
|
||||
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
||||
throw new Error(`rejecting attempt to load non-http URL '${urlStr}'`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user