Skip to content

Commit

Permalink
Properly escape facet value on the url
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Apr 19, 2012
1 parent d06c0ac commit c15051a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Raven.Client.Lightweight/Connection/ServerClient.cs
Expand Up @@ -1301,7 +1301,7 @@ public IEnumerable<string> GetTerms(string index, string field, string fromValue
var requestUri = operationUrl + string.Format("/facets/{0}?facetDoc={1}&query={2}",
Uri.EscapeUriString(index),
Uri.EscapeDataString(facetSetupDoc),
Uri.EscapeDataString(query.Query));
Uri.EscapeUriString(Uri.EscapeDataString(query.Query)));
var request = jsonRequestFactory.CreateHttpJsonRequest(this, requestUri, "GET", credentials, convention);
request.AddOperationHeaders(OperationsHeaders);
Expand Down
87 changes: 44 additions & 43 deletions Raven.Tests/Faceted/FacetedIndex.cs
Expand Up @@ -28,36 +28,36 @@ public FacetedIndex()
{
_data = FacetedIndexTestHelper.GetCameras(NumCameras);

_facets = new List<Facet>
{
new Facet {Name = "Manufacturer"},
//default is term query
//In Lucene [ is inclusive, { is exclusive
new Facet
{
Name = "Cost_Range",
Mode = FacetMode.Ranges,
Ranges =
{
"[NULL TO Dx200.0]",
"[Dx200.0 TO Dx400.0]",
"[Dx400.0 TO Dx600.0]",
"[Dx600.0 TO Dx800.0]",
"[Dx800.0 TO NULL]",
}
},
new Facet
{
Name = "Megapixels_Range",
Mode = FacetMode.Ranges,
Ranges =
{
"[NULL TO Dx3.0]",
"[Dx3.0 TO Dx7.0]",
"[Dx7.0 TO Dx10.0]",
"[Dx10.0 TO NULL]",
}
}
_facets = new List<Facet>
{
new Facet {Name = "Manufacturer"},
//default is term query
//In Lucene [ is inclusive, { is exclusive
new Facet
{
Name = "Cost_Range",
Mode = FacetMode.Ranges,
Ranges =
{
"[NULL TO Dx200.0]",
"[Dx200.0 TO Dx400.0]",
"[Dx400.0 TO Dx600.0]",
"[Dx600.0 TO Dx800.0]",
"[Dx800.0 TO NULL]",
}
},
new Facet
{
Name = "Megapixels_Range",
Mode = FacetMode.Ranges,
Ranges =
{
"[NULL TO Dx3.0]",
"[Dx3.0 TO Dx7.0]",
"[Dx7.0 TO Dx10.0]",
"[Dx10.0 TO NULL]",
}
}
};
}

Expand Down Expand Up @@ -172,11 +172,12 @@ private void ExecuteTest(IDocumentStore store)

using (var s = store.OpenSession())
{
var expressions = new Expression<Func<Camera, bool>>[]
{
x => x.Cost >= 100 && x.Cost <= 300,
x => x.DateOfListing > new DateTime(2000, 1, 1),
x => x.Megapixels > 5.0m && x.Cost < 500
var expressions = new Expression<Func<Camera, bool>>[]
{
x => x.Cost >= 100 && x.Cost <= 300,
x => x.DateOfListing > new DateTime(2000, 1, 1),
x => x.Megapixels > 5.0m && x.Cost < 500,
x => x.Manufacturer == "abc&edf"
};

foreach (var exp in expressions)
Expand Down Expand Up @@ -206,14 +207,14 @@ private void Setup(IDocumentStore store)
new IndexDefinition
{
Map =
@"from camera in docs
select new
{
camera.Manufacturer,
camera.Model,
camera.Cost,
camera.DateOfListing,
camera.Megapixels
@"from camera in docs
select new
{
camera.Manufacturer,
camera.Model,
camera.Cost,
camera.DateOfListing,
camera.Megapixels
}"
});

Expand Down

0 comments on commit c15051a

Please sign in to comment.