X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fmisc%2FStringUtil.java;h=f9c996a731e0f301df0baaad0b1df11099fb6294;hb=29da699109ce8842d02b60abcdb0dfdc4aa4f0db;hp=ac5536149c4271437418625077269abdd7558926;hpb=7cceb33aa6141506ca8cfb7952790ec5c912681b;p=mir.git diff --git a/source/mir/misc/StringUtil.java b/source/mir/misc/StringUtil.java index ac553614..f9c996a7 100755 --- a/source/mir/misc/StringUtil.java +++ b/source/mir/misc/StringUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001, 2002 The Mir-coders group + * Copyright (C) 2001, 2002 The Mir-coders group * * This file is part of Mir. * @@ -18,35 +18,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your version. */ - package mir.misc; -import java.io.*; -import java.lang.*; -import java.util.*; -import java.text.NumberFormat; -import gnu.regexp.*; +import gnu.regexp.RE; +import gnu.regexp.REException; + +import java.text.NumberFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; /** * Statische Hilfsmethoden zur Stringbehandlung * - * @version $Id: StringUtil.java,v 1.29 2002/12/02 12:33:23 zapata Exp $ + * @version $Id: StringUtil.java,v 1.33.2.5 2003/10/23 14:55:28 rk Exp $ * @author mir-coders group * */ public final class StringUtil { - private static RE re_newline2br, re_brbr2p, re_mail, re_url, re_tags; + private static RE re_newline2br, re_brbr2p, re_mail, re_url, re_tags, + re_tables, re_forbiddenTags; private StringUtil() { } // this avoids contruction @@ -55,9 +57,11 @@ public final class StringUtil { //precompile regex re_newline2br = new RE("(\r?\n){1}"); re_brbr2p = new RE("(
\r?\n
){1,}"); - re_mail = new RE("([a-zA-Z0-9_.-]+)@([a-zA-Z0-9_-]+)\\.([a-zA-Z0-9_.-]+)"); + re_mail = new RE("\\b([a-zA-Z0-9_.-]+)@([a-zA-Z0-9_-]+)\\.([a-zA-Z0-9_.-]+)\\b"); re_url = new RE("((https://)|(http://)|(ftp://)){1}([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/?([^ \t\r\n<>\\)\\]]+[^ \t\r\n.,<>\\)\\]])"); re_tags = new RE("<[^>]*>",RE.REG_ICASE); + re_tables = new RE("<[ \t\r\n/]*(table|td|tr)[ \t\r\n]*>",RE.REG_ICASE); + re_forbiddenTags = new RE("<[ \t\r\n/]*(html|meta|body|head|script)[ \t\r\n]*>",RE.REG_ICASE); } catch (REException e){ System.err.println("FATAL: StringUtil: could not precompile REGEX: "+e.toString()); @@ -120,7 +124,7 @@ public final class StringUtil { webdbDate.append("-"); webdbDate.append(pad2(theDate.get(Calendar.DATE))); webdbDate.append("T"); - webdbDate.append(pad2(theDate.get(Calendar.HOUR))); + webdbDate.append(pad2(theDate.get(Calendar.HOUR_OF_DAY))); webdbDate.append(":"); webdbDate.append(pad2(theDate.get(Calendar.MINUTE))); webdbDate.append(":"); @@ -162,17 +166,15 @@ public final class StringUtil { * this method deletes all