From f5baf5339168770500fd5798e9cf840cf7f45ef7 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 5 Jan 2011 17:35:36 +0000 Subject: [PATCH] fix for oob in snippet generation git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7425 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/yacysearchitem.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index 0647212be..5e833b877 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -243,8 +243,9 @@ public class yacysearchitem { final int p = s.lastIndexOf('.'); if (p < 0) return s.substring(0, length - 3) + "..."; assert p >= 0; - assert length - (s.length() - p) - 3 >= 0: "length = " + length + ", s.length() = " + s.length() + ", p = " + p; - return s.substring(0, length - (s.length() - p) - 3) + "..." + s.substring(p); // TODO check oob + String ext = s.substring(p + 1); + if (ext.length() > 4) return s.substring(0, length / 2 - 2) + "..." + s.substring(s.length() - (length / 2 - 2)); + return s.substring(0, length - ext.length() - 3) + "..." + ext; } private static String sizename(int size) {