File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -687,6 +687,16 @@ impl GlobalContext {
687687                    }  => anyhow ! ( 
688688                        "unexpected variable `{variable}` in build.build-dir path `{raw_template}`" 
689689                    ) , 
690+                     path:: ResolveTemplateError :: UnexpectedBracket  {  bracket_type,  raw_template }  => { 
691+                         let  ( btype,  literal)  = match  bracket_type { 
692+                             path:: BracketType :: Opening  => ( "opening" ,  "{" ) , 
693+                             path:: BracketType :: Closing  => ( "closing" ,  "}" ) , 
694+                         } ; 
695+ 
696+                         anyhow ! ( 
697+                             "unexpected {btype} bracket `{literal}` in build.build-dir path `{raw_template}`" 
698+                         ) 
699+                     } 
690700                } ) ?; 
691701
692702            // Check if the target directory is set to an empty string in the config.toml file. 
Original file line number Diff line number Diff line change @@ -58,6 +58,20 @@ impl ConfigRelativePath {
5858            } ) ; 
5959        } ; 
6060
61+         if  value. contains ( "{" )  { 
62+             return  Err ( ResolveTemplateError :: UnexpectedBracket  { 
63+                 bracket_type :  BracketType :: Opening , 
64+                 raw_template :  self . 0 . val . clone ( ) , 
65+             } ) ; 
66+         } 
67+ 
68+         if  value. contains ( "}" )  { 
69+             return  Err ( ResolveTemplateError :: UnexpectedBracket  { 
70+                 bracket_type :  BracketType :: Closing , 
71+                 raw_template :  self . 0 . val . clone ( ) , 
72+             } ) ; 
73+         } 
74+ 
6175        Ok ( self . 0 . definition . root ( gctx) . join ( & value) ) 
6276    } 
6377
@@ -139,4 +153,14 @@ pub enum ResolveTemplateError {
139153        variable :  String , 
140154        raw_template :  String , 
141155    } , 
156+     UnexpectedBracket  { 
157+         bracket_type :  BracketType , 
158+         raw_template :  String , 
159+     } , 
160+ } 
161+ 
162+ #[ derive( Debug ) ]  
163+ pub  enum  BracketType  { 
164+     Opening , 
165+     Closing , 
142166} 
Original file line number Diff line number Diff line change @@ -685,7 +685,7 @@ fn template_workspace_path_hash_should_handle_symlink() {
685685} 
686686
687687#[ cargo_test]  
688- fn  template_should_handle_ignore_unmatched_brackets ( )  { 
688+ fn  template_should_handle_reject_unmatched_brackets ( )  { 
689689    let  p = project ( ) 
690690        . file ( "src/lib.rs" ,  "" ) 
691691        . file ( 
@@ -700,6 +700,11 @@ fn template_should_handle_ignore_unmatched_brackets() {
700700    p. cargo ( "build -Z build-dir" ) 
701701        . masquerade_as_nightly_cargo ( & [ "build-dir" ] ) 
702702        . enable_mac_dsym ( ) 
703+         . with_status ( 101 ) 
704+         . with_stderr_data ( str![ [ r#" 
705+ [ERROR] unexpected opening bracket `{` in build.build-dir path `foo/{bar` 
706+ 
707+ "# ] ] ) 
703708        . run ( ) ; 
704709
705710    let  p = project ( ) 
@@ -716,6 +721,11 @@ fn template_should_handle_ignore_unmatched_brackets() {
716721    p. cargo ( "build -Z build-dir" ) 
717722        . masquerade_as_nightly_cargo ( & [ "build-dir" ] ) 
718723        . enable_mac_dsym ( ) 
724+         . with_status ( 101 ) 
725+         . with_stderr_data ( str![ [ r#" 
726+ [ERROR] unexpected closing bracket `}` in build.build-dir path `foo/}bar` 
727+ 
728+ "# ] ] ) 
719729        . run ( ) ; 
720730} 
721731
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments