Skip to content

Commit

Permalink
Sanitize shortcut names
Browse files Browse the repository at this point in the history
  • Loading branch information
andyvorld committed Feb 14, 2023
1 parent 0cef6c8 commit a8cddfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
"react-markdown": "^8.0.3",
"react-router-dom": "^6.3.0",
"recharts": "^2.1.14",
"sanitize-filename": "^1.6.3",
"shlex": "^2.1.2",
"short-uuid": "^4.2.0",
"simple-keyboard": "^3.4.136",
Expand Down
7 changes: 5 additions & 2 deletions src/backend/shortcuts/shortcuts/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { isMac, userHome } from '../../constants'
import { GOGLibrary } from '../../gog/library'
import { getIcon } from '../utils'
import { addNonSteamGame } from '../nonesteamgame/nonesteamgame'
import sanitize from 'sanitize-filename'

/**
* Adds a desktop shortcut to $HOME/Desktop and to /usr/share/applications
Expand Down Expand Up @@ -139,6 +140,8 @@ function shortcutFiles(gameTitle: string) {
let desktopFile
let menuFile

gameTitle = sanitize(gameTitle)

switch (process.platform) {
case 'linux': {
desktopFile = `${app.getPath('desktop')}/${gameTitle}.desktop`
Expand All @@ -162,11 +165,11 @@ function shortcutFiles(gameTitle: string) {
}

async function generateMacOsApp(gameInfo: GameInfo | SideloadGame) {
const { title, app_name } = gameInfo
const { app_name } = gameInfo

logInfo('Generating macOS shortcut', LogPrefix.Backend)

const appShortcut = join(userHome, 'Applications', `${title}.app`)
const appShortcut = shortcutFiles(gameInfo.title)[0]!
const macOSFolder = `${appShortcut}/Contents/MacOS`
const resourcesFolder = `${appShortcut}/Contents/Resources`
const plistFile = `${appShortcut}/Contents/Info.plist`
Expand Down

0 comments on commit a8cddfa

Please sign in to comment.