Commit b8dbfe1a authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Fix links to IP addresses in same /24.

Fixes #27266.
parent dc87c84c
# Changes in version 3.0.1 - 2018-08-??
* Medium changes
- Fix links to IP addresses in same /24.
# Changes in version 3.0.0 - 2018-08-13 # Changes in version 3.0.0 - 2018-08-13
* Major changes * Major changes
......
...@@ -215,7 +215,7 @@ public class ExoneraTorServlet extends HttpServlet { ...@@ -215,7 +215,7 @@ public class ExoneraTorServlet extends HttpServlet {
statusEntries); statusEntries);
} else if (addressesInSameNetwork != null } else if (addressesInSameNetwork != null
&& !addressesInSameNetwork.isEmpty()) { && !addressesInSameNetwork.isEmpty()) {
this.writeSummaryAddressesInSameNetwork(out, rb, relayIp, this.writeSummaryAddressesInSameNetwork(out, rb, requestUrl, relayIp,
requestedDate.asString, langStr, addressesInSameNetwork); requestedDate.asString, langStr, addressesInSameNetwork);
} else { } else {
this.writeSummaryNegative(out, rb, relayIp, requestedDate.asString); this.writeSummaryNegative(out, rb, relayIp, requestedDate.asString);
...@@ -464,8 +464,8 @@ public class ExoneraTorServlet extends HttpServlet { ...@@ -464,8 +464,8 @@ public class ExoneraTorServlet extends HttpServlet {
} }
void writeSummaryAddressesInSameNetwork(PrintWriter out, void writeSummaryAddressesInSameNetwork(PrintWriter out,
ResourceBundle rb, String relayIp, String timestampStr, String langStr, ResourceBundle rb, String requestUrl, String relayIp, String timestampStr,
List<String> addressesInSameNetwork) { String langStr, List<String> addressesInSameNetwork) {
Object[][] panelItems = new Object[addressesInSameNetwork.size()][]; Object[][] panelItems = new Object[addressesInSameNetwork.size()][];
for (int i = 0; i < addressesInSameNetwork.size(); i++) { for (int i = 0; i < addressesInSameNetwork.size(); i++) {
String addressInSameNetwork = addressesInSameNetwork.get(i); String addressInSameNetwork = addressesInSameNetwork.get(i);
...@@ -473,12 +473,12 @@ public class ExoneraTorServlet extends HttpServlet { ...@@ -473,12 +473,12 @@ public class ExoneraTorServlet extends HttpServlet {
String address; String address;
if (addressInSameNetwork.contains(":")) { if (addressInSameNetwork.contains(":")) {
address = addressInSameNetwork.replaceAll("[\\[\\]]", ""); address = addressInSameNetwork.replaceAll("[\\[\\]]", "");
link = String.format("/?ip=[%s]&timestamp=%s&lang=%s", link = String.format("%s?ip=[%s]&timestamp=%s&lang=%s",
address.replaceAll(":", "%3A"), timestampStr, langStr); requestUrl, address.replaceAll(":", "%3A"), timestampStr, langStr);
address = "[" + address + "]"; address = "[" + address + "]";
} else { } else {
link = String.format("/?ip=%s&timestamp=%s&lang=%s", link = String.format("%s?ip=%s&timestamp=%s&lang=%s",
addressInSameNetwork, timestampStr, langStr); requestUrl, addressInSameNetwork, timestampStr, langStr);
address = addressInSameNetwork; address = addressInSameNetwork;
} }
panelItems[i] = new Object[] { link, address }; panelItems[i] = new Object[] { link, address };
......
...@@ -49,7 +49,7 @@ public class ExoneraTorServletTest { ...@@ -49,7 +49,7 @@ public class ExoneraTorServletTest {
for (QueryResponse qr : qrs) { for (QueryResponse qr : qrs) {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
es.writeSummaryAddressesInSameNetwork(new PrintWriter(sw), rb, es.writeSummaryAddressesInSameNetwork(new PrintWriter(sw), rb,
qr.queryAddress, qr.queryDate, "en", "http://localhost:8080/", qr.queryAddress, qr.queryDate, "en",
Arrays.asList(qr.nearbyAddresses)); Arrays.asList(qr.nearbyAddresses));
String errorMsg = "Test data:" + QueryResponse.toJson(qr) String errorMsg = "Test data:" + QueryResponse.toJson(qr)
+ "\nresult:\n" + sw.toString(); + "\nresult:\n" + sw.toString();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment