File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
lib/dsc-lib/src/functions Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -42,14 +42,11 @@ impl Function for ResourceId {
4242 }
4343 // ARM uses a slash separator, but here we use a colon which is not allowed for the type nor name
4444 result. push ( ':' ) ;
45- // second argument is the name and must contain no slashes
45+ // second argument is the name and we url encode it to ensure no unexpected characters are present
4646 let resource_name = & args[ 1 ] ;
4747 if let Some ( value) = resource_name. as_str ( ) {
48- if value. contains ( '/' ) {
49- return Err ( DscError :: Function ( "resourceId" . to_string ( ) , t ! ( "functions.resourceId.incorrectNameFormat" ) . to_string ( ) ) ) ;
50- }
51-
52- result. push_str ( value) ;
48+ let encoded = urlencoding:: encode ( value) ;
49+ result. push_str ( & encoded) ;
5350 } else {
5451 return Err ( DscError :: Parser ( t ! ( "functions.resourceId.invalidSecondArgType" ) . to_string ( ) ) ) ;
5552 }
@@ -85,10 +82,10 @@ mod tests {
8582 }
8683
8784 #[ test]
88- fn invalid_name ( ) {
85+ fn valid_name_with_slashes ( ) {
8986 let mut parser = Statement :: new ( ) . unwrap ( ) ;
90- let result = parser. parse_and_execute ( "[resourceId('a','b/c')]" , & Context :: new ( ) ) ;
91- assert ! ( result. is_err ( ) ) ;
87+ let result = parser. parse_and_execute ( "[resourceId('a','b/c')]" , & Context :: new ( ) ) . unwrap ( ) ;
88+ assert_eq ! ( result, "a:b%2Fc" ) ;
9289 }
9390
9491 #[ test]
You can’t perform that action at this time.
0 commit comments