@@ -684,14 +684,18 @@ private ConnectionString BuildResolvedConnectionString(ConnectionStringScheme re
684
684
. AllKeys
685
685
. SelectMany ( key => resolvedOptions
686
686
. GetValues ( key )
687
- . Select ( value => $ "{ key } ={ Uri . EscapeDataString ( value ) } ") ) ) ;
687
+ . Select ( value => $ "{ key } ={ EscapeOptionValue ( key , value ) } ") ) ) ;
688
688
689
689
if ( mergedOptions . Count > 0 )
690
690
{
691
691
connectionString += "?" + string . Join ( "&" , mergedOptions ) ;
692
692
}
693
693
694
694
return new ConnectionString ( connectionString , isResolved : true ) ;
695
+
696
+ string EscapeOptionValue ( string key , string value )
697
+ => string . Equals ( key , "authmechanismproperties" , StringComparison . OrdinalIgnoreCase ) ? value : Uri . EscapeDataString ( value ) ;
698
+
695
699
}
696
700
697
701
private void ExtractScheme ( Match match )
@@ -758,7 +762,13 @@ private void ExtractOptions(Match match)
758
762
var parts = option . Value . Split ( '=' ) ;
759
763
var name = parts [ 0 ] . Trim ( ) ;
760
764
var value = parts [ 1 ] . Trim ( ) ;
761
- _allOptions . Add ( name , Uri . UnescapeDataString ( value ) ) ;
765
+ // Should not decode authmechanismproperties before splitting by separator.
766
+ if ( ! string . Equals ( name , "authmechanismproperties" , StringComparison . OrdinalIgnoreCase ) )
767
+ {
768
+ value = Uri . UnescapeDataString ( value ) ;
769
+ }
770
+
771
+ _allOptions . Add ( name , value ) ;
762
772
ParseOption ( name , value ) ;
763
773
}
764
774
}
@@ -902,12 +912,6 @@ string ProtectConnectionString(string connectionString)
902
912
903
913
private void ParseOption ( string name , string value )
904
914
{
905
- // Should not decode authmechanismproperties before splitting by separator.
906
- if ( ! string . Equals ( name , "authmechanismproperties" , StringComparison . OrdinalIgnoreCase ) )
907
- {
908
- value = Uri . UnescapeDataString ( value ) ;
909
- }
910
-
911
915
switch ( name . ToLowerInvariant ( ) )
912
916
{
913
917
case "appname" :
0 commit comments