Skip to content

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

fixed some more bad handling of byte[]

orbiter09987e93fdfd
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index 9b5da3084..4e9d97754 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -97,7 +97,7 @@ public class IndexControlRWIs_p {
}
if (post.containsKey("keyhashsearch")) {
- if (keystring.length() == 0 || !Word.word2hash(keystring).equals(keyhash)) {
+ if (keystring.length() == 0 || !new String(Word.word2hash(keystring)).equals(new String(keyhash))) {
prop.put("keystring", "<not possible to compute word from hash>");
}
final plasmaSearchRankingProcess ranking = plasmaSearchAPI.genSearchresult(prop, sb, keyhash, null);
@@ -171,7 +171,7 @@ public class IndexControlRWIs_p {
}
if (post.containsKey("urllist")) {
- if (keystring.length() == 0 || !Word.word2hash(keystring).equals(keyhash)) {
+ if (keystring.length() == 0 || !new String(Word.word2hash(keystring)).equals(new String(keyhash))) {
prop.put("keystring", "<not possible to compute word from hash>");
}
final Bitfield flags = plasmaSearchAPI.compileFlags(post);
@@ -182,7 +182,7 @@ public class IndexControlRWIs_p {
// transfer to other peer
if (post.containsKey("keyhashtransfer")) try {
- if (keystring.length() == 0 || !Word.word2hash(keystring).equals(keyhash)) {
+ if (keystring.length() == 0 || !new String(Word.word2hash(keystring)).equals(new String(keyhash))) {
prop.put("keystring", "<not possible to compute word from hash>");
}
diff --git a/htroot/ViewImage.java b/htroot/ViewImage.java
index 82efbfc1f..2a3d44923 100644
--- a/htroot/ViewImage.java
+++ b/htroot/ViewImage.java
@@ -123,7 +123,7 @@ public class ViewImage {
// read image
final Image image = ymageImageParser.parse(urlString, imgb);
- if ((auth) && ((width == 0) || (height == 0)) && (maxwidth == 0) && (maxheight == 0)) return image;
+ if (image == null || (auth && (width == 0 || height == 0) && maxwidth == 0 && maxheight == 0)) return image;
// find original size
final int h = image.getHeight(null);
diff --git a/source/de/anomic/plasma/parser/Condenser.java b/source/de/anomic/plasma/parser/Condenser.java
index a620dcf15..a3aa6a3fc 100644
--- a/source/de/anomic/plasma/parser/Condenser.java
+++ b/source/de/anomic/plasma/parser/Condenser.java
@@ -733,7 +733,7 @@ public final class Condenser {
final String s = p.getProperty("keywords" + i);
final String[] l = s.split(",");
for (int j = 0; j < l.length; j++) {
- sb.append(Word.word2hash(l[j]));
+ sb.append(new String(Word.word2hash(l[j])));
}
if (i < 15) sb.append(",\n");
}
diff --git a/source/de/anomic/plasma/plasmaSearchQuery.java b/source/de/anomic/plasma/plasmaSearchQuery.java
index 73e600a58..f5b736f6f 100644
--- a/source/de/anomic/plasma/plasmaSearchQuery.java
+++ b/source/de/anomic/plasma/plasmaSearchQuery.java
@@ -313,7 +313,7 @@ public final class plasmaSearchQuery {
"*" + this.domType +
"*" + this.contentdom +
"*" + this.zonecode +
- "*" + Word.word2hash(this.ranking.toExternalString()) +
+ "*" + new String(Word.word2hash(this.ranking.toExternalString())) +
"*" + this.prefer +
"*" + this.urlMask +
"*" + this.targetlang +
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index 814697bb6..0e593dfcf 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -230,14 +230,14 @@ public class plasmaSnippetCache {
for(int k=0; k < word.length(); k++) {
//is character a special character?
if(p4.matcher(word.substring(k,k+1)).find()) {
- if (Word.word2hash(temp).equals(h)) temp = "<b>" + htmlFilterCharacterCoding.unicode2html(temp, false) + "</b>";
+ if (new String(Word.word2hash(temp)).equals(new String(h))) temp = "<b>" + htmlFilterCharacterCoding.unicode2html(temp, false) + "</b>";
out = out + temp + htmlFilterCharacterCoding.unicode2html(word.substring(k,k+1), false);
temp = "";
}
//last character
else if(k == (word.length()-1)) {
temp = temp + word.substring(k,k+1);
- if (Word.word2hash(temp).equals(h)) temp = "<b>" + htmlFilterCharacterCoding.unicode2html(temp, false) + "</b>";
+ if (new String(Word.word2hash(temp)).equals(new String(h))) temp = "<b>" + htmlFilterCharacterCoding.unicode2html(temp, false) + "</b>";
out = out + temp;
temp = "";
}
@@ -247,7 +247,7 @@ public class plasmaSnippetCache {
}
//end contrib [MN]
- else if (Word.word2hash(word).equals(h)) word = "<b>" + htmlFilterCharacterCoding.unicode2html(word, false) + "</b>";
+ else if (new String(Word.word2hash(word)).equals(new String(h))) word = "<b>" + htmlFilterCharacterCoding.unicode2html(word, false) + "</b>";
word = htmlFilterCharacterCoding.unicode2html(prefix, false)
+ word
diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java
index 626009772..a10fc5b15 100644
--- a/source/de/anomic/server/serverObjects.java
+++ b/source/de/anomic/server/serverObjects.java
@@ -102,7 +102,12 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
* @return the previous value as String.
*/
public String put(final String key, final byte[] value) {
- return this.put(key, new String(value)); //TODO: do we need an encoding method for byte[]?
+ try {
+ return this.put(key, new String(value, "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ return null;
+ }
}
/**
diff --git a/source/de/anomic/ymage/ymageICOParser.java b/source/de/anomic/ymage/ymageICOParser.java
index b089a0769..4399518bf 100644
--- a/source/de/anomic/ymage/ymageICOParser.java
+++ b/source/de/anomic/ymage/ymageICOParser.java
@@ -88,6 +88,7 @@ public class ymageICOParser {
}
public BufferedImage getImage(final int index) {
+ if (imagemaps == null || index >= imagemaps.length) return null;
return imagemaps[index].image;
}