@@ -160,7 +160,7 @@ public class SIPCallDescriptor
160160 public SIPCallDescriptor ( ISIPAccount toSIPAccount , string uri , string fromHeader , string contentType , string content )
161161 {
162162 ToSIPAccount = toSIPAccount ;
163- Uri = uri ?? toSIPAccount . SIPUsername + "@" + toSIPAccount . SIPDomain ;
163+ Uri = uri ?? $ " { toSIPAccount . SIPUsername } @ { toSIPAccount . SIPDomain } " ;
164164 From = fromHeader ;
165165 ContentType = contentType ;
166166 Content = content ;
@@ -291,14 +291,14 @@ public void ParseCallOptions(string options)
291291 options = options . Trim ( '[' , ']' ) ;
292292
293293 // Parse delay time option.
294- Match delayCallMatch = Regex . Match ( options , DELAY_CALL_OPTION_KEY + @" =(?<delaytime>\d+)") ;
294+ Match delayCallMatch = Regex . Match ( options , $@ " { DELAY_CALL_OPTION_KEY } =(?<delaytime>\d+)") ;
295295 if ( delayCallMatch . Success )
296296 {
297297 int . TryParse ( delayCallMatch . Result ( "${delaytime}" ) , out DelaySeconds ) ;
298298 }
299299
300300 // Parse redirect mode option.
301- Match redirectModeMatch = Regex . Match ( options , REDIRECT_MODE_OPTION_KEY + @" =(?<redirectmode>\w)") ;
301+ Match redirectModeMatch = Regex . Match ( options , $@ " { REDIRECT_MODE_OPTION_KEY } =(?<redirectmode>\w)") ;
302302 if ( redirectModeMatch . Success )
303303 {
304304 string redirectMode = redirectModeMatch . Result ( "${redirectmode}" ) ;
@@ -321,42 +321,42 @@ public void ParseCallOptions(string options)
321321 }
322322
323323 // Parse call duration limit option.
324- Match callDurationMatch = Regex . Match ( options , CALL_DURATION_OPTION_KEY + @" =(?<callduration>\d+)") ;
324+ Match callDurationMatch = Regex . Match ( options , $@ " { CALL_DURATION_OPTION_KEY } =(?<callduration>\d+)") ;
325325 if ( callDurationMatch . Success )
326326 {
327327 int . TryParse ( callDurationMatch . Result ( "${callduration}" ) , out CallDurationLimit ) ;
328328 }
329329
330330 // Parse the mangle option.
331- Match mangleMatch = Regex . Match ( options , MANGLE_MODE_OPTION_KEY + @" =(?<mangle>\w+)") ;
331+ Match mangleMatch = Regex . Match ( options , $@ " { MANGLE_MODE_OPTION_KEY } =(?<mangle>\w+)") ;
332332 if ( mangleMatch . Success )
333333 {
334334 bool . TryParse ( mangleMatch . Result ( "${mangle}" ) , out MangleResponseSDP ) ;
335335 }
336336
337337 // Parse the From header display name option.
338- Match fromDisplayNameMatch = Regex . Match ( options , FROM_DISPLAY_NAME_KEY + @" =(?<displayname>.+?)(,|$)") ;
338+ Match fromDisplayNameMatch = Regex . Match ( options , $@ " { FROM_DISPLAY_NAME_KEY } =(?<displayname>.+?)(,|$)") ;
339339 if ( fromDisplayNameMatch . Success )
340340 {
341341 FromDisplayName = fromDisplayNameMatch . Result ( "${displayname}" ) . Trim ( ) ;
342342 }
343343
344344 // Parse the From header URI username option.
345- Match fromUsernameNameMatch = Regex . Match ( options , FROM_USERNAME_KEY + @" =(?<username>.+?)(,|$)") ;
345+ Match fromUsernameNameMatch = Regex . Match ( options , $@ " { FROM_USERNAME_KEY } =(?<username>.+?)(,|$)") ;
346346 if ( fromUsernameNameMatch . Success )
347347 {
348348 FromURIUsername = fromUsernameNameMatch . Result ( "${username}" ) . Trim ( ) ;
349349 }
350350
351351 // Parse the From header URI host option.
352- Match fromURIHostMatch = Regex . Match ( options , FROM_HOST_KEY + @" =(?<host>.+?)(,|$)") ;
352+ Match fromURIHostMatch = Regex . Match ( options , $@ " { FROM_HOST_KEY } =(?<host>.+?)(,|$)") ;
353353 if ( fromURIHostMatch . Success )
354354 {
355355 FromURIHost = fromURIHostMatch . Result ( "${host}" ) . Trim ( ) ;
356356 }
357357
358358 // Parse the Transfer behaviour option.
359- Match transferMatch = Regex . Match ( options , TRANSFER_MODE_OPTION_KEY + @" =(?<transfermode>.+?)(,|$)") ;
359+ Match transferMatch = Regex . Match ( options , $@ " { TRANSFER_MODE_OPTION_KEY } =(?<transfermode>.+?)(,|$)") ;
360360 if ( transferMatch . Success )
361361 {
362362 string transferMode = transferMatch . Result ( "${transfermode}" ) ;
@@ -387,28 +387,28 @@ public void ParseCallOptions(string options)
387387 }
388388
389389 // Parse the request caller details option.
390- Match callerDetailsMatch = Regex . Match ( options , REQUEST_CALLER_DETAILS + @" =(?<callerdetails>\w+)") ;
390+ Match callerDetailsMatch = Regex . Match ( options , $@ " { REQUEST_CALLER_DETAILS } =(?<callerdetails>\w+)") ;
391391 if ( callerDetailsMatch . Success )
392392 {
393393 bool . TryParse ( callerDetailsMatch . Result ( "${callerdetails}" ) , out RequestCallerDetails ) ;
394394 }
395395
396396 // Parse the accountcode.
397- Match accountCodeMatch = Regex . Match ( options , ACCOUNT_CODE_KEY + @" =(?<accountCode>\w+)") ;
397+ Match accountCodeMatch = Regex . Match ( options , $@ " { ACCOUNT_CODE_KEY } =(?<accountCode>\w+)") ;
398398 if ( accountCodeMatch . Success )
399399 {
400400 AccountCode = accountCodeMatch . Result ( "${accountCode}" ) ;
401401 }
402402
403403 // Parse the rate code.
404- Match rateCodeMatch = Regex . Match ( options , RATE_CODE_KEY + @" =(?<rateCode>\w+)") ;
404+ Match rateCodeMatch = Regex . Match ( options , $@ " { RATE_CODE_KEY } =(?<rateCode>\w+)") ;
405405 if ( rateCodeMatch . Success )
406406 {
407407 RateCode = rateCodeMatch . Result ( "${rateCode}" ) ;
408408 }
409409
410410 // Parse the delayed reinvite option.
411- Match delayedReinviteMatch = Regex . Match ( options , DELAYED_REINVITE_KEY + @" =(?<delayedReinvite>\d+)") ;
411+ Match delayedReinviteMatch = Regex . Match ( options , $@ " { DELAYED_REINVITE_KEY } =(?<delayedReinvite>\d+)") ;
412412 if ( delayedReinviteMatch . Success )
413413 {
414414 int . TryParse ( delayedReinviteMatch . Result ( "${delayedReinvite}" ) , out ReinviteDelay ) ;
@@ -457,7 +457,14 @@ public static List<string> ParseCustomHeaders(string customHeaders)
457457 //string headerName = customHeader.Substring(0, colonIndex).Trim();
458458 //string headerValue = (customHeader.Length > colonIndex) ? customHeader.Substring(colonIndex + 1).Trim() : String.Empty;
459459
460- if ( Regex . Match ( customHeader . Trim ( ) , "^(Via|From|Contact|CSeq|Call-ID|Max-Forwards|Content-Length)$" , RegexOptions . IgnoreCase ) . Success )
460+ var trimmedCustomHeader = customHeader . AsSpan ( ) . Trim ( ) ;
461+ if ( trimmedCustomHeader . Equals ( SIPHeaders . SIP_HEADER_VIA , StringComparison . OrdinalIgnoreCase ) ||
462+ trimmedCustomHeader . Equals ( SIPHeaders . SIP_HEADER_FROM , StringComparison . OrdinalIgnoreCase ) ||
463+ trimmedCustomHeader . Equals ( SIPHeaders . SIP_HEADER_CONTACT , StringComparison . OrdinalIgnoreCase ) ||
464+ trimmedCustomHeader . Equals ( SIPHeaders . SIP_HEADER_CSEQ , StringComparison . OrdinalIgnoreCase ) ||
465+ trimmedCustomHeader . Equals ( SIPHeaders . SIP_HEADER_CALLID , StringComparison . OrdinalIgnoreCase ) ||
466+ trimmedCustomHeader . Equals ( SIPHeaders . SIP_HEADER_MAXFORWARDS , StringComparison . OrdinalIgnoreCase ) ||
467+ trimmedCustomHeader . Equals ( SIPHeaders . SIP_HEADER_CONTENTLENGTH , StringComparison . OrdinalIgnoreCase ) )
461468 {
462469 logger . LogWarning ( "ParseCustomHeaders skipping custom header due to an non-permitted string in header name, {CustomHeader}." , customHeader ) ;
463470 continue ;
0 commit comments