Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize shortcut names #2449

Merged
Merged
Show file tree
Hide file tree
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
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