Skip to content

Commit a69e839

Browse files
committed
Regex.Replace -> case_insensitive, fixed cli parms lcase
1 parent 73baa28 commit a69e839

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

Synapse.Core/Utilities/XmlHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ internal static string RegexReplaceOrValue(string input, string replacement, Dyn
197197
if( dv != null )
198198
{
199199
if( !string.IsNullOrWhiteSpace( dv.Replace ) )
200-
value = Regex.Replace( input, dv.Replace, replacement );
200+
value = Regex.Replace( input, dv.Replace, replacement, RegexOptions.IgnoreCase );
201201

202202
if( !string.IsNullOrWhiteSpace( dv.Encode ) && dv.Encode.ToLower() == "base64" )
203203
value = CryptoHelpers.Encode( value );

Synapse.Core/Utilities/YamlHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ internal static object RegexReplaceOrValue(object input, object replacement, Dyn
188188
if( dv != null )
189189
{
190190
if( !string.IsNullOrWhiteSpace( dv.Replace ) )
191-
value = Regex.Replace( input.ToString(), dv.Replace, replacement.ToString() );
191+
value = Regex.Replace( input.ToString(), dv.Replace, replacement.ToString(), RegexOptions.IgnoreCase );
192192

193193
if( !string.IsNullOrWhiteSpace( dv.Encode ) && dv.Encode.ToLower() == "base64" )
194194
value = CryptoHelpers.Encode( value.ToString() );

Synapse.cli/Program.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ public Arguments(string[] args)
330330

331331
if( IsParsed )
332332
{
333-
Args = ParseCmdLine( args );
333+
Dictionary<string, string> origcase = new Dictionary<string, string>();
334+
Args = ParseCmdLine( args, ref origcase );
334335

335336
#region Plan
336337
if( Args.Keys.Contains( __plan ) )
@@ -497,6 +498,12 @@ public Arguments(string[] args)
497498
Verbose = false;
498499
}
499500
#endregion
501+
502+
//this returns a colleection with original casing from the cmdline parms
503+
Dictionary<string, string> newArgs = new Dictionary<string, string>();
504+
foreach( string key in Args.Keys )
505+
newArgs.Add( origcase[key], Args[key] );
506+
Args = newArgs;
500507
}
501508

502509
IsParsed &= string.IsNullOrWhiteSpace( Message );
@@ -523,7 +530,7 @@ public Arguments(string[] args)
523530
public bool IsSample { get { return !string.IsNullOrWhiteSpace( Sample ); } }
524531
public bool Verbose { get; internal set; }
525532

526-
Dictionary<string, string> ParseCmdLine(string[] args)
533+
Dictionary<string, string> ParseCmdLine(string[] args, ref Dictionary<string, string> origcase)
527534
{
528535
IsParsed = true;
529536
Dictionary<string, string> options = new Dictionary<string, string>();
@@ -537,8 +544,10 @@ Dictionary<string, string> ParseCmdLine(string[] args)
537544
// If match not found, command line args are improperly formed.
538545
if( match.Success )
539546
{
540-
options[match.Groups["argname"].Value.ToLower().TrimStart( '/' )] =
541-
match.Groups["argvalue"].Value;
547+
string orig = match.Groups["argname"].Value.TrimStart( '/' );
548+
string lcase = orig.ToLower();
549+
options[lcase] = match.Groups["argvalue"].Value;
550+
origcase[lcase] = orig;
542551
}
543552
else
544553
{

0 commit comments

Comments
 (0)