Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) make Blacklist_p.html more failsafe if no blacklist file is available of the user has entered empty strings

theli4abc04dac0ec
diff --git a/htroot/Blacklist_p.html b/htroot/Blacklist_p.html
index 3ceeb3d0b..f1d0a6489 100644
--- a/htroot/Blacklist_p.html
+++ b/htroot/Blacklist_p.html
@@ -33,7 +33,7 @@ collect blacklist entries from other peers.</p>
</select>
</td>
<td class="TableCellDark"><center>
- <input type="submit" name="selectList" value="select" />
+ <input type="submit" name="selectList" value="select" disabled="#(disabled)#::disabled#(/disabled)#"/>
</td>
<td valign="top" align="left" rowspan="2" class="TableCellDark">
<fieldset>
@@ -45,11 +45,11 @@ collect blacklist entries from other peers.</p>
</tr>
#{/currentActiveFor}#
</table>
- <input type="submit" name="activateList" value="Enable/disable this list">
+ <input type="submit" name="activateList" value="Enable/disable this list" disabled="#(disabled)#::disabled#(/disabled)#"/>
</fieldset>
- <input type="submit" name="shareList" value="Share/don't share this list" /><br />
- <input type="submit" name="deleteList" value="Delete this list" /><br />
+ <input type="submit" name="shareList" value="Share/don't share this list" disabled="#(disabled)#::disabled#(/disabled)#"/><br />
+ <input type="submit" name="deleteList" value="Delete this list" disabled="#(disabled)#::disabled#(/disabled)#"/><br />
</td>
</tr>
<tr>
@@ -70,7 +70,7 @@ collect blacklist entries from other peers.</p>
<!-- Blacklist configuration -->
<tr>
<td colspan="3" valign="top" class="TableHeader">
- <h3>Active list: <i>#[currentBlacklist]#</i></h3>
+ <h3>Active list: <i>#[currentBlacklist]#</i>#(disabled)#::<font style="color:red;font-weight:bold">No blacklist selected</font>#(/disabled)#</h3>
</td>
</tr>
<tr>
@@ -94,7 +94,7 @@ collect blacklist entries from other peers.</p>
#{/Itemlist}#
</select>
<p />
- <input type="submit" name="deleteBlacklistEntry" value="Delete URL pattern">
+ <input type="submit" name="deleteBlacklistEntry" value="Delete URL pattern" disabled="#(disabled)#::disabled#(/disabled)#" />
</td>
</tr>
<tr>
@@ -113,7 +113,7 @@ collect blacklist entries from other peers.</p>
<tr>
<td class="TableCellLight">
<input type="text" name="newEntry" size="50"><p>
- <input type="submit" name="addBlacklistEntry" value="Add URL pattern"></p>
+ <input type="submit" name="addBlacklistEntry" value="Add URL pattern" disabled="#(disabled)#::disabled#(/disabled)#"></p>
</td>
</tr>
@@ -140,7 +140,7 @@ collect blacklist entries from other peers.</p>
#{/otherHosts}#
</select>
<p />
- <input type="submit" value="Load new blacklist items">
+ <input type="submit" value="Load new blacklist items" disabled="#(disabled)#::disabled#(/disabled)#"/>
</form>
</td>
</tr>
@@ -156,7 +156,7 @@ collect blacklist entries from other peers.</p>
<input type="hidden" name="currentBlacklist" value="#[currentBlacklist]#">
URL: <input type="text" name="url">
<p>
- <input type="submit" value="Load new blacklist items">
+ <input type="submit" value="Load new blacklist items" disabled="#(disabled)#::disabled#(/disabled)#"/>
</form>
</td>
</tr>
@@ -172,7 +172,7 @@ collect blacklist entries from other peers.</p>
<input type="hidden" name="currentBlacklist" value="#[currentBlacklist]#">
File: <input type="text" name="file">
<p>
- <input type="submit" value="Load new blacklist items">
+ <input type="submit" value="Load new blacklist items" disabled="#(disabled)#::disabled#(/disabled)#"/>
</form>
</td>
</tr>
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java
index dc2a77980..23af91473 100644
--- a/htroot/Blacklist_p.java
+++ b/htroot/Blacklist_p.java
@@ -85,6 +85,7 @@ public class Blacklist_p {
if (post.containsKey("selectList")) {
blacklistToUse = (String)post.get("selectedListName");
+ if (blacklistToUse != null && blacklistToUse.length() == 0) blacklistToUse = null;
}
if (post.containsKey("createNewList")) {
/* ===========================================================
@@ -92,6 +93,11 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = (String)post.get("newListName");
+ if (blacklistToUse.trim().length() == 0) {
+ prop.put("LOCATION","");
+ return prop;
+ }
+
if (!blacklistToUse.endsWith(".black")) blacklistToUse += ".black";
try {
@@ -113,6 +119,10 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = (String)post.get("selectedListName");
+ if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
+ prop.put("LOCATION","");
+ return prop;
+ }
File BlackListFile = new File(listManager.listsPath, blacklistToUse);
BlackListFile.delete();
@@ -135,6 +145,10 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = (String)post.get("selectedListName");
+ if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
+ prop.put("LOCATION","");
+ return prop;
+ }
for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
if (post.containsKey("activateList4" + supportedBlacklistTypes[blTypes])) {
@@ -153,6 +167,10 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = (String)post.get("selectedListName");
+ if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
+ prop.put("LOCATION","");
+ return prop;
+ }
if (listManager.ListInListslist(BLACKLIST_SHARED, blacklistToUse)) {
// Remove from shared BlackLists
@@ -168,9 +186,17 @@ public class Blacklist_p {
// get the current selected blacklist name
blacklistToUse = (String)post.get("currentBlacklist");
+ if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
+ prop.put("LOCATION","");
+ return prop;
+ }
// get the entry that should be deleted
String oldEntry = (String)post.get("selectedEntry");
+ if (oldEntry.trim().length() == 0) {
+ prop.put("LOCATION",header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse);
+ return prop;
+ }
// load blacklist data from file
ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse));
@@ -205,9 +231,17 @@ public class Blacklist_p {
* Add a new blacklist entry
* =========================================================== */
- blacklistToUse = (String)post.get("currentBlacklist");
+ blacklistToUse = (String)post.get("currentBlacklist");
+ if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {
+ prop.put("LOCATION","");
+ return prop;
+ }
String newEntry = (String)post.get("newEntry");
+ if (newEntry.trim().length() == 0) {
+ prop.put("LOCATION",header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse);
+ return prop;
+ }
// TODO: ignore empty entries
@@ -334,7 +368,8 @@ public class Blacklist_p {
}
prop.put("blackLists", blacklistCount);
- prop.put("currentBlacklist", blacklistToUse);
+ prop.put("currentBlacklist", (blacklistToUse==null)?"":blacklistToUse);
+ prop.put("disabled", (blacklistToUse==null)?1:0);
return prop;
}