Skip to content

Commit cc4009a

Browse files
committed
removed trying to set UnescapeDotsAndSlashes on internal m_Flags which breaks support for mono
1 parent b11ea30 commit cc4009a

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

Diff for: src/Nest/Domain/Connection/Connection.cs

+4-35
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,9 @@ private Uri _CreateUriString(string path)
346346
var qs = s.QueryStringParameters.ToQueryString(tempUri.Query.IsNullOrEmpty() ? "?" : "&");
347347
path += qs;
348348
}
349-
LeaveDotsAndSlashesEscaped(s.Uri);
349+
path = this._ConnectionSettings.DontDoubleEscapePathDotsAndSlashes ? path : path.Replace("%2F", "%252F");
350350
var uri = new Uri(s.Uri, path);
351-
LeaveDotsAndSlashesEscaped(uri);
352-
return uri;
353-
var url = s.Uri.AbsoluteUri + path;
351+
354352
//WebRequest.Create will replace %2F with /
355353
//this is a 'security feature'
356354
//see http://mikehadlow.blogspot.nl/2011/08/how-to-stop-systemuri-un-escaping.html
@@ -360,38 +358,9 @@ private Uri _CreateUriString(string path)
360358
//If you manually set the config settings to NOT forefully unescape dots and slashes be sure to call
361359
//.SetDontDoubleEscapePathDotsAndSlashes() on the connection settings.
362360
//return );
363-
364-
//return this._ConnectionSettings.DontDoubleEscapePathDotsAndSlashes ? url : url.Replace("%2F", "%252F");
361+
//
362+
return uri;
365363
}
366364

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-
}
396365
}
397366
}

0 commit comments

Comments
 (0)