@@ -346,11 +346,9 @@ private Uri _CreateUriString(string path)
346
346
var qs = s . QueryStringParameters . ToQueryString ( tempUri . Query . IsNullOrEmpty ( ) ? "?" : "&" ) ;
347
347
path += qs ;
348
348
}
349
- LeaveDotsAndSlashesEscaped ( s . Uri ) ;
349
+ path = this . _ConnectionSettings . DontDoubleEscapePathDotsAndSlashes ? path : path . Replace ( "%2F" , "%252F" ) ;
350
350
var uri = new Uri ( s . Uri , path ) ;
351
- LeaveDotsAndSlashesEscaped ( uri ) ;
352
- return uri ;
353
- var url = s . Uri . AbsoluteUri + path ;
351
+
354
352
//WebRequest.Create will replace %2F with /
355
353
//this is a 'security feature'
356
354
//see http://mikehadlow.blogspot.nl/2011/08/how-to-stop-systemuri-un-escaping.html
@@ -360,38 +358,9 @@ private Uri _CreateUriString(string path)
360
358
//If you manually set the config settings to NOT forefully unescape dots and slashes be sure to call
361
359
//.SetDontDoubleEscapePathDotsAndSlashes() on the connection settings.
362
360
//return );
363
-
364
- // return this._ConnectionSettings.DontDoubleEscapePathDotsAndSlashes ? url : url.Replace("%2F", "%252F") ;
361
+ //
362
+ return uri ;
365
363
}
366
364
367
- // System.UriSyntaxFlags is internal, so let's duplicate the flag privately
368
- private const int UnEscapeDotsAndSlashes = 0x2000000 ;
369
-
370
- public static void LeaveDotsAndSlashesEscaped ( Uri uri )
371
- {
372
- if ( uri == null )
373
- {
374
- throw new ArgumentNullException ( "uri" ) ;
375
- }
376
-
377
- FieldInfo fieldInfo = uri . GetType ( ) . GetField ( "m_Syntax" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
378
- if ( fieldInfo == null )
379
- {
380
- throw new MissingFieldException ( "'m_Syntax' field not found" ) ;
381
- }
382
- object uriParser = fieldInfo . GetValue ( uri ) ;
383
-
384
- fieldInfo = typeof ( UriParser ) . GetField ( "m_Flags" , BindingFlags . Instance | BindingFlags . NonPublic ) ;
385
- if ( fieldInfo == null )
386
- {
387
- throw new MissingFieldException ( "'m_Flags' field not found" ) ;
388
- }
389
- object uriSyntaxFlags = fieldInfo . GetValue ( uriParser ) ;
390
-
391
- // Clear the flag that we don't want
392
- uriSyntaxFlags = ( int ) uriSyntaxFlags & ~ UnEscapeDotsAndSlashes ;
393
-
394
- fieldInfo . SetValue ( uriParser , uriSyntaxFlags ) ;
395
- }
396
365
}
397
366
}
0 commit comments