more validation
This commit is contained in:
@ -150,3 +150,27 @@ input[type=submit]:hover {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[type=reset] {
|
||||||
|
border: 1px outset #999;
|
||||||
|
background: #ddf;
|
||||||
|
color: #001;
|
||||||
|
margin: 5px;
|
||||||
|
font: bold 8pt "Lucida Sans Unicode", "Bitstream Vera Sans", Verdana, Tahoma, Helvetica, sans-serif;
|
||||||
|
padding: 1px 2px;
|
||||||
|
text-decoration: none;
|
||||||
|
min-width: 110px;
|
||||||
|
border-radius: 4px;
|
||||||
|
-moz-border-radius: 4px;
|
||||||
|
-khtml-border-radius: 4px;
|
||||||
|
-moz-box-shadow: inset 0px 2px 8px 0px #fff;
|
||||||
|
color: #006;
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=reset]:hover {
|
||||||
|
background: #22a;
|
||||||
|
color: #fff;
|
||||||
|
border: 1px solid #f60;
|
||||||
|
opacity: 1.0;
|
||||||
|
-moz-box-shadow: inset 0px 0px 0px 1px #fff;
|
||||||
|
}
|
||||||
|
@ -35,7 +35,9 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import net.i2p.data.DataFormatException;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
|
import net.i2p.data.Destination;
|
||||||
|
|
||||||
public class AddressbookBean
|
public class AddressbookBean
|
||||||
{
|
{
|
||||||
@ -254,15 +256,40 @@ public class AddressbookBean
|
|||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
String name = null;
|
String name = null;
|
||||||
if (action.equals(_("Add"))) {
|
if (action.equals(_("Add")) || action.equals(_("Replace"))) {
|
||||||
if( addressbook != null && hostname != null && destination != null ) {
|
if( addressbook != null && hostname != null && destination != null ) {
|
||||||
addressbook.put( hostname, destination );
|
String oldDest = (String) addressbook.get(hostname);
|
||||||
changed = true;
|
if (destination.equals(oldDest)) {
|
||||||
message = _("Destination added.");
|
message = _("Host name {0} is already in addressbook, unchanged.", hostname);
|
||||||
// clear search when adding
|
} else if (oldDest != null && !action.equals(_("Replace"))) {
|
||||||
search = null;
|
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;
|
||||||
|
} else {
|
||||||
|
message = _("Invalid Base 64 destination.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message = _("Please enter a host name and destination");
|
||||||
}
|
}
|
||||||
} else if (action.equals(_("Delete"))) {
|
// clear search when adding
|
||||||
|
search = null;
|
||||||
|
} else if (action.equals(_("Delete Selected"))) {
|
||||||
Iterator it = deletionMarks.iterator();
|
Iterator it = deletionMarks.iterator();
|
||||||
while( it.hasNext() ) {
|
while( it.hasNext() ) {
|
||||||
name = (String)it.next();
|
name = (String)it.next();
|
||||||
@ -340,7 +367,7 @@ public class AddressbookBean
|
|||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
public void setDestination(String destination) {
|
public void setDestination(String destination) {
|
||||||
this.destination = DataHelper.stripHTML(destination); // XSS
|
this.destination = DataHelper.stripHTML(destination).trim(); // XSS
|
||||||
}
|
}
|
||||||
public String getHostname() {
|
public String getHostname() {
|
||||||
return hostname;
|
return hostname;
|
||||||
@ -352,7 +379,7 @@ public class AddressbookBean
|
|||||||
deletionMarks.addLast( name );
|
deletionMarks.addLast( name );
|
||||||
}
|
}
|
||||||
public void setHostname(String hostname) {
|
public void setHostname(String hostname) {
|
||||||
this.hostname = DataHelper.stripHTML(hostname); // XSS
|
this.hostname = DataHelper.stripHTML(hostname).trim(); // XSS
|
||||||
}
|
}
|
||||||
private int getBeginInt() {
|
private int getBeginInt() {
|
||||||
return Math.max(0, Math.min(entries.length - 1, beginIndex));
|
return Math.max(0, Math.min(entries.length - 1, beginIndex));
|
||||||
|
@ -160,7 +160,9 @@
|
|||||||
|
|
||||||
<c:if test="${book.master || book.router || book.published || book.private}">
|
<c:if test="${book.master || book.router || book.published || book.private}">
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<p class="buttons"><input type="submit" name="action" value="<%=intl._("Delete")%>" >
|
<p class="buttons">
|
||||||
|
<input type="reset" value="<%=intl._("Cancel")%>" >
|
||||||
|
<input type="submit" name="action" value="<%=intl._("Delete Selected")%>" >
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
</c:if>
|
||||||
@ -179,6 +181,7 @@
|
|||||||
<b><%=intl._("Hostname")%>:</b> <input type="text" name="hostname" value="${book.hostname}" size="20">
|
<b><%=intl._("Hostname")%>:</b> <input type="text" name="hostname" value="${book.hostname}" size="20">
|
||||||
<b><%=intl._("Destination")%>:</b> <textarea name="destination" rows="1" style="height: 3em;" cols="40" wrap="off" >${book.destination}</textarea><br/>
|
<b><%=intl._("Destination")%>:</b> <textarea name="destination" rows="1" style="height: 3em;" cols="40" wrap="off" >${book.destination}</textarea><br/>
|
||||||
</p><p>
|
</p><p>
|
||||||
|
<input type="submit" name="action" value="<%=intl._("Replace")%>" >
|
||||||
<input type="submit" name="action" value="<%=intl._("Add")%>" >
|
<input type="submit" name="action" value="<%=intl._("Add")%>" >
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -69,8 +69,8 @@
|
|||||||
<textarea name="config" rows="10" cols="80">${cfg.config}</textarea>
|
<textarea name="config" rows="10" cols="80">${cfg.config}</textarea>
|
||||||
</div>
|
</div>
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<input type="submit" name="action" value="<%=intl._("Save")%>" >
|
|
||||||
<input type="submit" name="action" value="<%=intl._("Reload")%>" >
|
<input type="submit" name="action" value="<%=intl._("Reload")%>" >
|
||||||
|
<input type="submit" name="action" value="<%=intl._("Save")%>" >
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="help">
|
<div id="help">
|
||||||
|
@ -69,8 +69,8 @@
|
|||||||
<textarea name="content" rows="10" cols="80">${subs.content}</textarea>
|
<textarea name="content" rows="10" cols="80">${subs.content}</textarea>
|
||||||
</div>
|
</div>
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<input type="submit" name="action" value="<%=intl._("Save")%>" >
|
|
||||||
<input type="submit" name="action" value="<%=intl._("Reload")%>" >
|
<input type="submit" name="action" value="<%=intl._("Reload")%>" >
|
||||||
|
<input type="submit" name="action" value="<%=intl._("Save")%>" >
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div id="help">
|
<div id="help">
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2010-05-19 zzz
|
||||||
|
* Data: Remove lots of unnecessary initializers
|
||||||
|
* susidns: More validataion when adding entry
|
||||||
|
|
||||||
2010-05-15 zzz
|
2010-05-15 zzz
|
||||||
* Console:
|
* Console:
|
||||||
- Tag text in graphs
|
- Tag text in graphs
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 7;
|
public final static long BUILD = 8;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user