@@ -700,21 +700,29 @@ func (p *TransferSIPParticipantRequest) Validate() error {
700700 }
701701
702702 // Validate TransferTo URI format and ensure RFC compliance
703- var uriToValidate string
703+ var innerURI string
704704 if strings .HasPrefix (p .TransferTo , "<" ) && strings .HasSuffix (p .TransferTo , ">" ) {
705705 // Extract inner URI for validation
706- uriToValidate = p .TransferTo [1 : len (p .TransferTo )- 1 ]
706+ innerURI = p .TransferTo [1 : len (p .TransferTo )- 1 ]
707707 } else {
708- uriToValidate = p .TransferTo
708+ innerURI = p .TransferTo
709709 }
710710
711- if ! strings .HasPrefix (uriToValidate , "sip:" ) && ! strings .HasPrefix (uriToValidate , "tel:" ) {
711+ if ! strings .HasPrefix (innerURI , "sip:" ) && ! strings .HasPrefix (innerURI , "tel:" ) {
712+ // In theory the Refer-To header can receive the full name-addr.
713+ // This can make this check inaccurate, but we want to limit to just SIP and TEL URIs.
712714 return errors .New ("transfer_to must be a valid SIP or TEL URI (sip: or tel:)" )
713715 }
714716
715- // Ensure RFC compliance by wrapping in angle brackets if not already wrapped
716- if ! strings .HasPrefix (p .TransferTo , "<" ) || ! strings .HasSuffix (p .TransferTo , ">" ) {
717- p .TransferTo = fmt .Sprintf ("<%s>" , p .TransferTo )
717+ if strings .HasPrefix (innerURI , "sip:" ) {
718+ // addr-spec = sip:...
719+ // name-addr = [ display-name ] <addr-spec>
720+ // Both name-addr and addr-spec are allowed in RFC3515 (section-2.1).
721+ // However, name-addr is more premissive and widely-supported, so we convert.
722+ p .TransferTo = fmt .Sprintf ("<%s>" , innerURI )
723+ } else {
724+ // tel: URIs are not explicitly allowed in spec, but are generally supported.
725+ p .TransferTo = innerURI
718726 }
719727
720728 if err := validateHeaderKeys (p .Headers ); err != nil {
0 commit comments