Skip to content

Commit 459ea50

Browse files
committed
GetFull does not escape id's properly
1 parent c981e5a commit 459ea50

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

src/Nest.Connection.Thrift/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1616
[assembly: System.CLSCompliant(true)]
1717
[assembly: System.Runtime.InteropServices.Guid("4d165338-2060-4641-8be6-b7aacbdee52d")]
18-
[assembly: System.Reflection.AssemblyVersion("0.11.0.0")]
19-
[assembly: System.Reflection.AssemblyFileVersion("0.11.0.0")]
18+
[assembly: System.Reflection.AssemblyVersion("0.11.1.0")]
19+
[assembly: System.Reflection.AssemblyFileVersion("0.11.1.0")]
2020

2121

src/Nest.Dsl.Factory/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1717
[assembly: System.CLSCompliant(true)]
1818
[assembly: System.Runtime.InteropServices.Guid("665cc582-c91f-4f6c-924a-614289fa9449")]
19-
[assembly: System.Reflection.AssemblyVersion("0.11.0.0")]
20-
[assembly: System.Reflection.AssemblyFileVersion("0.11.0.0")]
19+
[assembly: System.Reflection.AssemblyVersion("0.11.1.0")]
20+
[assembly: System.Reflection.AssemblyFileVersion("0.11.1.0")]
2121

2222

src/Nest.Tests.Unit/Core/Get/GetFullTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ public void GetUsingDescriptor()
4242
StringAssert.EndsWith("/myindex/elasticsearchprojects/404", status.RequestUrl);
4343
}
4444
[Test]
45+
public void GetUsingDescriptorEscapes()
46+
{
47+
var result = this._client.GetFull<ElasticSearchProject>(g => g
48+
.Index("myindex")
49+
.Id("myid/with/slashes")
50+
);
51+
var status = result.ConnectionStatus;
52+
StringAssert.EndsWith("/myindex/elasticsearchprojects/myid%252Fwith%252Fslashes", status.RequestUrl);
53+
}
54+
[Test]
4555
public void GetUsingDescriptorWithType()
4656
{
4757
var result = this._client.GetFull<ElasticSearchProject>(g => g

src/Nest/ElasticClient-GetFull.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,28 @@ public IGetResponse<T> GetFull<T>(string id) where T : class
2929
index.ThrowIfNullOrEmpty("Cannot infer default index for current connection.");
3030

3131
var typeName = this.GetTypeNameFor<T>();
32-
33-
return this.GetFull<T>(id, this.PathResolver.CreateIndexTypePath(index, typeName));
32+
var path = this.PathResolver.CreateIndexTypeIdPath(index, typeName, id);
33+
return this._GetFull<T>(path);
3434
}
3535
/// <summary>
3636
/// Gets a document of T by id in the specified index and the specified typename
3737
/// </summary>
3838
/// <returns>an instance of T</returns>
3939
public IGetResponse<T> GetFull<T>(string index, string type, string id) where T : class
4040
{
41-
return this.GetFull<T>(id, index + "/" + type + "/");
41+
var path = this.PathResolver.CreateIndexTypeIdPath(index, type, id);
42+
return this._GetFull<T>(path);
4243
}
4344
/// <summary>
4445
/// Gets a document of T by id in the specified index and the specified typename
4546
/// </summary>
4647
/// <returns>an instance of T</returns>
4748
public IGetResponse<T> GetFull<T>(string index, string type, int id) where T : class
4849
{
49-
return this.GetFull<T>(id.ToString(), index + "/" + type + "/");
50-
}
51-
private IGetResponse<T> GetFull<T>(string id, string path) where T : class
52-
{
53-
return this._GetFull<T>(path + id);
50+
var path = this.PathResolver.CreateIndexTypeIdPath(index, type, id.ToString());
51+
return this._GetFull<T>(path);
5452
}
53+
5554

5655
public IGetResponse<T> GetFull<T>(Action<GetDescriptor<T>> getSelector) where T : class
5756
{

src/Nest/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[assembly: System.Runtime.InteropServices.ComVisible(false)]
1616
[assembly: System.CLSCompliant(true)]
1717
[assembly: System.Runtime.InteropServices.Guid("07E5CFA3-CF5F-4D17-874C-8D5CC6FA3E73")]
18-
[assembly: System.Reflection.AssemblyVersion("0.11.0.0")]
19-
[assembly: System.Reflection.AssemblyFileVersion("0.11.0.0")]
18+
[assembly: System.Reflection.AssemblyVersion("0.11.1.0")]
19+
[assembly: System.Reflection.AssemblyFileVersion("0.11.1.0")]
2020

2121

src/Nest/Resolvers/PathResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public string CreateGetPath<T>(GetDescriptor<T> d) where T : class
3939
var id = d._Id;
4040
id.ThrowIfNullOrEmpty("id");
4141

42-
var path = string.Format("/{0}/{1}/{2}", index, type.Resolve(this._connectionSettings), id);
42+
var path = "/{0}/{1}/{2}".EscapedFormat(index, type.Resolve(this._connectionSettings), id);
4343
var urlParams = new Dictionary<string, string>();
4444
if (d._Refresh.HasValue)
4545
urlParams.Add("refresh", d._Refresh.Value.ToString().ToLower());

0 commit comments

Comments
 (0)