diff --git a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java index 02ff07081a5dece0c9ea93aaa455f5d8c8fe829b..52d67ab8e7893307ad7cee43da5844067938cb06 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java @@ -281,31 +281,42 @@ public class AddressbookBean boolean changed = false; if (action.equals(_("Add")) || action.equals(_("Replace"))) { if( addressbook != null && hostname != null && destination != null ) { - String oldDest = (String) addressbook.get(hostname); - if (destination.equals(oldDest)) { - message = _("Host name {0} is already in addressbook, unchanged.", hostname); - } else if (oldDest != null && !action.equals(_("Replace"))) { - message = _("Host name {0} is already in addressbook with a different destination. Click \"Replace\" to overwrite.", hostname); - } else { - boolean valid = true; - try { - Destination dest = new Destination(destination); - } catch (DataFormatException dfe) { - valid = false; - } - if (valid) { - addressbook.put( hostname, destination ); - changed = true; - if (oldDest == null) - message = _("Destination added for {0}.", hostname); - else - message = _("Destination changed for {0}.", hostname); - // clear form - hostname = null; - destination = null; + try { + // throws IAE with translated message + String host = AddressBean.toASCII(hostname); + String displayHost = host.equals(hostname) ? hostname : + hostname + " (" + host + ')'; + + String oldDest = (String) addressbook.get(host); + if (destination.equals(oldDest)) { + message = _("Host name {0} is already in addressbook, unchanged.", displayHost); + } else if (oldDest != null && !action.equals(_("Replace"))) { + message = _("Host name {0} is already in addressbook with a different destination. Click \"Replace\" to overwrite.", displayHost); } else { - message = _("Invalid Base 64 destination."); + boolean valid = true; + try { + Destination dest = new Destination(destination); + } catch (DataFormatException dfe) { + valid = false; + } + if (valid) { + addressbook.put( host, destination ); + changed = true; + if (oldDest == null) + message = _("Destination added for {0}.", displayHost); + else + message = _("Destination changed for {0}.", displayHost); + // clear form + hostname = null; + destination = null; + } else { + message = _("Invalid Base 64 destination."); + } } + } catch (IllegalArgumentException iae) { + message = iae.getMessage(); + if (message == null) + message = _("Invalid host name \"{0}\".", hostname); } } else { message = _("Please enter a host name and destination"); @@ -317,9 +328,11 @@ public class AddressbookBean int deleted = 0; for (String n : deletionMarks) { addressbook.remove(n); + String uni = AddressBean.toUnicode(n); + String displayHost = uni.equals(n) ? n : uni + " (" + n + ')'; if (deleted++ == 0) { changed = true; - name = n; + name = displayHost; } } if( changed ) { diff --git a/apps/susidns/src/jsp/addressbook.jsp b/apps/susidns/src/jsp/addressbook.jsp index 6258e0a8bdbb72be087c45e1dfd93a2e0fe81b2b..103620ff30c78ac438876a31f9996d287134fbd1 100644 --- a/apps/susidns/src/jsp/addressbook.jsp +++ b/apps/susidns/src/jsp/addressbook.jsp @@ -103,6 +103,7 @@ ${book.loadBookMessages} <a href="addressbook.jsp?filter=y&begin=0&end=99">y</a> <a href="addressbook.jsp?filter=z&begin=0&end=99">z</a> <a href="addressbook.jsp?filter=0-9&begin=0&end=99">0-9</a> +<a href="addressbook.jsp?filter=xn--&begin=0&end=99"><%=intl._("other")%></a> <a href="addressbook.jsp?filter=none&begin=0&end=99"><%=intl._("all")%></a></p> <c:if test="${book.hasFilter}"> <p><%=intl._("Current filter")%>: ${book.filter} @@ -150,11 +151,11 @@ ${book.loadBookMessages} <c:if test="${book.master || book.router || book.published || book.private}"> <td class="checkbox"><input type="checkbox" name="checked" value="${addr.name}" title="<%=intl._("Mark for deletion")%>"></td> </c:if> -<td class="names"><a href="${addr.uri}">${addr.displayName}</a> +<td class="names"><a href="http://${addr.name}/">${addr.displayName}</a> </td><td class="names"> <span class="addrhlpr"><a href="http://${addr.b32}/" title="<%=intl._("Base 32 address")%>">b32</a></span> </td><td class="names"> -<span class="addrhlpr"><a href="details.jsp?h=${addr.query}" title="<%=intl._("More information on this entry")%>"><%=intl._("details")%></a></span> +<span class="addrhlpr"><a href="details.jsp?h=${addr.name}" title="<%=intl._("More information on this entry")%>"><%=intl._("details")%></a></span> </td> <td class="destinations"><textarea rows="1" style="height: 3em;" cols="40" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td> </tr>