Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit 7e3daa5

Browse files
committed
Fix for issue #862: Wrong encoding of query when updating histogram solution is changed
- links to change resolution of histogram now properly URLEncode parameters (like the query)
1 parent 7b16bc0 commit 7e3daa5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

app/views/helpers/DateHistogramResolutionSelector.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package views.helpers;
22

3+
import com.google.common.base.Charsets;
34
import com.google.common.collect.Maps;
45
import org.apache.commons.lang3.text.WordUtils;
56

67
import lib.SearchTools;
78
import play.mvc.Http;
89

10+
import java.io.UnsupportedEncodingException;
911
import java.util.Map;
1012

1113
public class DateHistogramResolutionSelector {
@@ -23,11 +25,17 @@ public static String getOptions(String selected, Http.Request request) {
2325
url.append("?");
2426

2527
for (Map.Entry<String, String[]> entry : queryParams.entrySet()) {
28+
2629
for (String value : entry.getValue()) {
27-
url.append(entry.getKey())
28-
.append("=")
29-
.append(value)
30-
.append("&");
30+
try {
31+
url.append(entry.getKey())
32+
.append("=")
33+
.append(java.net.URLEncoder.encode(value, Charsets.UTF_8.name()))
34+
.append("&");
35+
} catch (UnsupportedEncodingException e) {
36+
// UTF-8 *is* supported, but just in case...
37+
throw new RuntimeException(e);
38+
}
3139
}
3240
}
3341

0 commit comments

Comments
 (0)