11import { exec , spawn , toast } from 'kernelsu-alt' ;
2- import { modDir , persistDir , superkey , initInfo , MAX_CHUNK_SIZE , linkRedirect } from '../index.js' ;
2+ import { modDir , persistDir , superkey , initInfo , MAX_CHUNK_SIZE , linkRedirect , escapeShell } from '../index.js' ;
33import { getString } from '../language.js' ;
44
55let allKpms = [ ] ;
@@ -46,13 +46,13 @@ async function getKpmList() {
4646 }
4747
4848 const listResult = await exec (
49- `kpatch ' ${ superkey } ' kpm list && sh "${ modDir } /status.sh" ' ${ superkey } ' ` ,
49+ `kpatch ${ escapeShell ( superkey ) } kpm list && sh "${ modDir } /status.sh" ${ escapeShell ( superkey ) } ` ,
5050 { env : { PATH : `${ modDir } /bin:$PATH` } }
5151 ) ;
5252 const modules = listResult . stdout . trim ( ) . split ( '\n' ) . filter ( line => line . trim ( ) ) ;
5353
5454 const modulePromises = modules . map ( async ( moduleName ) => {
55- const infoResult = await exec ( `kpatch ' ${ superkey } ' kpm info "${ moduleName } "` , { env : { PATH : `${ modDir } /bin` } } ) ;
55+ const infoResult = await exec ( `kpatch ${ escapeShell ( superkey ) } kpm info "${ moduleName } "` , { env : { PATH : `${ modDir } /bin` } } ) ;
5656 const infoLines = infoResult . stdout . trim ( ) . split ( '\n' ) ;
5757
5858 const moduleInfo = { } ;
@@ -69,7 +69,7 @@ async function getKpmList() {
6969}
7070
7171async function controlModule ( moduleName , action ) {
72- const result = await exec ( `kpatch ' ${ superkey } ' kpm ctl0 "${ moduleName } " ${ action } ` , { env : { PATH : `${ modDir } /bin` } } ) ;
72+ const result = await exec ( `kpatch ${ escapeShell ( superkey ) } kpm ctl0 "${ moduleName } " ${ action } ` , { env : { PATH : `${ modDir } /bin` } } ) ;
7373 toast ( result . errno === 0 ? result . stdout : result . stderr ) ;
7474}
7575
@@ -79,12 +79,12 @@ function forgetModule(moduleName) {
7979
8080async function unloadModule ( moduleName ) {
8181 forgetModule ( moduleName ) ;
82- const result = await exec ( `kpatch ' ${ superkey } ' kpm unload "${ moduleName } "` , { env : { PATH : `${ modDir } /bin` } } ) ;
82+ const result = await exec ( `kpatch ${ escapeShell ( superkey ) } kpm unload "${ moduleName } "` , { env : { PATH : `${ modDir } /bin` } } ) ;
8383 return result . errno === 0 ;
8484}
8585
8686async function loadModule ( modulePath ) {
87- const result = await exec ( `kpatch ' ${ superkey } ' kpm load "${ modulePath } "` , { env : { PATH : `${ modDir } /bin` } } ) ;
87+ const result = await exec ( `kpatch ${ escapeShell ( superkey ) } kpm load "${ modulePath } "` , { env : { PATH : `${ modDir } /bin` } } ) ;
8888 return result . errno === 0 ;
8989}
9090
0 commit comments