@@ -16,9 +16,6 @@ use tauri_utils::html::{
1616 inject_nonce_token, parse as parse_html, serialize_node as serialize_html_node,
1717} ;
1818
19- #[ cfg( feature = "shell-scope" ) ]
20- use tauri_utils:: config:: { ShellAllowedArg , ShellAllowedArgs , ShellAllowlistScope } ;
21-
2219use crate :: embedded_assets:: { AssetOptions , CspHashes , EmbeddedAssets , EmbeddedAssetsError } ;
2320
2421/// Necessary data needed by [`context_codegen`] to generate code for a Tauri application context.
@@ -424,38 +421,6 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
424421 }
425422 } ;
426423
427- #[ cfg( feature = "shell-scope" ) ]
428- let with_shell_scope_code = {
429- use regex:: Regex ;
430- use tauri_utils:: config:: ShellAllowlistOpen ;
431-
432- let shell_scopes = get_allowed_clis ( & root, & config. tauri . allowlist . shell . scope ) ;
433-
434- let shell_scope_constructor = match & config. tauri . allowlist . shell . open {
435- ShellAllowlistOpen :: Flag ( false ) => quote ! ( #root:: ShellScopeConfig :: new( ) . skip_validation( ) ) ,
436- ShellAllowlistOpen :: Flag ( true ) => quote ! ( #root:: ShellScopeConfig :: new( ) ) ,
437- ShellAllowlistOpen :: Validate ( regex) => match Regex :: new ( regex) {
438- Ok ( _) => {
439- quote ! ( #root:: ShellScopeConfig :: with_validator( #root:: regex:: Regex :: new( #regex) . unwrap( ) ) )
440- }
441- Err ( error) => {
442- let error = error. to_string ( ) ;
443- quote ! ( {
444- compile_error!( #error) ;
445- #root:: ShellScopeConfig :: with_validator( #root:: regex:: Regex :: new( #regex) . unwrap( ) )
446- } )
447- }
448- } ,
449- _ => panic ! ( "unknown shell open format, unable to prepare" ) ,
450- } ;
451- let shell_scope = quote ! ( #shell_scope_constructor. set_allowed_commands( #shell_scopes) ) ;
452-
453- quote ! ( context. set_shell_scope( #shell_scope) ; )
454- } ;
455-
456- #[ cfg( not( feature = "shell-scope" ) ) ]
457- let with_shell_scope_code = quote ! ( ) ;
458-
459424 Ok ( quote ! ( {
460425 #[ allow( unused_mut, clippy:: let_and_return) ]
461426 let mut context = #root:: Context :: new(
@@ -468,7 +433,6 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
468433 #pattern,
469434 ) ;
470435 #with_system_tray_icon_code
471- #with_shell_scope_code
472436 context
473437 } ) )
474438}
@@ -587,78 +551,3 @@ fn find_icon<F: Fn(&&String) -> bool>(
587551 . unwrap_or_else ( || default. to_string ( ) ) ;
588552 config_parent. join ( icon_path)
589553}
590-
591- #[ cfg( feature = "shell-scope" ) ]
592- fn get_allowed_clis ( root : & TokenStream , scope : & ShellAllowlistScope ) -> TokenStream {
593- let commands = scope
594- . 0
595- . iter ( )
596- . map ( |scope| {
597- let sidecar = & scope. sidecar ;
598-
599- let name = & scope. name ;
600- let name = quote ! ( #name. into( ) ) ;
601-
602- let command = scope. command . to_string_lossy ( ) ;
603- let command = quote ! ( :: std:: path:: PathBuf :: from( #command) ) ;
604-
605- let args = match & scope. args {
606- ShellAllowedArgs :: Flag ( true ) => quote ! ( :: std:: option:: Option :: None ) ,
607- ShellAllowedArgs :: Flag ( false ) => quote ! ( :: std:: option:: Option :: Some ( :: std:: vec![ ] ) ) ,
608- ShellAllowedArgs :: List ( list) => {
609- let list = list. iter ( ) . map ( |arg| match arg {
610- ShellAllowedArg :: Fixed ( fixed) => {
611- quote ! ( #root:: scope:: ShellScopeAllowedArg :: Fixed ( #fixed. into( ) ) )
612- }
613- ShellAllowedArg :: Var { validator } => {
614- let validator = match regex:: Regex :: new ( validator) {
615- Ok ( regex) => {
616- let regex = regex. as_str ( ) ;
617- quote ! ( #root:: regex:: Regex :: new( #regex) . unwrap( ) )
618- }
619- Err ( error) => {
620- let error = error. to_string ( ) ;
621- quote ! ( {
622- compile_error!( #error) ;
623- #root:: regex:: Regex :: new( #validator) . unwrap( )
624- } )
625- }
626- } ;
627-
628- quote ! ( #root:: scope:: ShellScopeAllowedArg :: Var { validator: #validator } )
629- }
630- _ => panic ! ( "unknown shell scope arg, unable to prepare" ) ,
631- } ) ;
632-
633- quote ! ( :: std:: option:: Option :: Some ( :: std:: vec![ #( #list) , * ] ) )
634- }
635- _ => panic ! ( "unknown shell scope command, unable to prepare" ) ,
636- } ;
637-
638- (
639- quote ! ( #name) ,
640- quote ! (
641- #root:: scope:: ShellScopeAllowedCommand {
642- command: #command,
643- args: #args,
644- sidecar: #sidecar,
645- }
646- ) ,
647- )
648- } )
649- . collect :: < Vec < _ > > ( ) ;
650-
651- if commands. is_empty ( ) {
652- quote ! ( :: std:: collections:: HashMap :: new( ) )
653- } else {
654- let insertions = commands
655- . iter ( )
656- . map ( |( name, value) | quote ! ( hashmap. insert( #name, #value) ; ) ) ;
657-
658- quote ! ( {
659- let mut hashmap = :: std:: collections:: HashMap :: new( ) ;
660- #( #insertions) *
661- hashmap
662- } )
663- }
664- }
0 commit comments