File tree Expand file tree Collapse file tree
nym-vpn-app/src/screens/settings/split-tunneling Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import { Spinner } from '../../../ui';
1212import InfoDialog from './InfoDialog' ;
1313import LaunchConfirmDialog from './LaunchConfirmDialog' ;
1414import AppItem , { AppEntry } from './AppItem' ;
15- import { useSplitTunnel } from './utils' ;
15+ import { parseExecArgs , useSplitTunnel } from './utils' ;
1616import { PROBLEMATIC_APPS } from './utils/constants' ;
1717
1818function SplitTunneling ( ) {
@@ -35,7 +35,7 @@ function SplitTunneling() {
3535 try {
3636 const command = Command . create (
3737 'nym-exclude' ,
38- app . executable_path . split ( ' ' ) ,
38+ parseExecArgs ( app . executable_path ) ,
3939 ) ;
4040
4141 command . on ( 'close' , ( data ) => {
Original file line number Diff line number Diff line change 11export * from './useSplitTunnel' ;
2+ export * from './parseExec' ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Parses a desktop entry Exec= value into an argument list suitable for
3+ * passing to Command.create().
4+ *
5+ * Per the XDG Desktop Entry Specification:
6+ * - If the executable path contains spaces it MUST be wrapped in double quotes
7+ * and spaces inside the quoted path MUST be escaped as \s.
8+ * - Arguments following the executable are separated by regular spaces.
9+ *
10+ * Examples:
11+ * '/usr/bin/firefox' → ['/usr/bin/firefox']
12+ * '/usr/bin/app --flag' → ['/usr/bin/app', '--flag']
13+ * '"/opt/My\sApp/app" --flag' → ['/opt/My App/app', '--flag']
14+ */
15+ export function parseExecArgs ( exec : string ) : string [ ] {
16+ const trimmed = exec . trim ( ) ;
17+
18+ if ( trimmed . startsWith ( '"' ) ) {
19+ const closingQuote = trimmed . indexOf ( '"' , 1 ) ;
20+ if ( closingQuote !== - 1 ) {
21+ const path = trimmed . slice ( 1 , closingQuote ) . replace ( / \\ s / g, ' ' ) ;
22+ const rest = trimmed . slice ( closingQuote + 1 ) . trim ( ) ;
23+ return [ path , ...rest . split ( ' ' ) . filter ( Boolean ) ] ;
24+ }
25+ }
26+
27+ // Unquoted path: split on spaces as before
28+ return trimmed . split ( ' ' ) . filter ( Boolean ) ;
29+ }
You can’t perform that action at this time.
0 commit comments