Java tutorial
/* * @(#)ValidatorExt.java * * Copyright (c) 2006 CyberVietnam, Inc. * 185 Giang Vo street, Ba Dinh district, Hanoi, Vietnam. * All rights reserved. * * This software is the confidential and proprietary information of * CyberVietnam, Inc. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered * into with CyberVietnam, Inc. * */ package com.vportal.portal.util; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import org.apache.regexp.RE; /** * * @author VPortal Group (2008), VSI * */ public class ValidatorExt extends Validator { private static String prohibitedWords = "(\\w*)shit(\\w*)|(\\w*)cyber(\\w*)|(\\w*)name(\\w*)|(\\w*)poop(\\w*)|(\\w*)ch\u00ednh ph\u1ee7(\\w*)|(\\w*)c\u1ed9ng s\u1ea3n(\\w*)|(\\w*)fuck(\\w*)|(\\w*)fucking(\\w*)|(\\w*)fucker(\\w*)|(\\w*)cunt(\\w*)|(\\w*)asshole(\\w*)|(\\w*)bitch(\\w*)|(\\w*)m\u1eb9 ki\u1ebfp(\\w*)|(\\w*)ch\u00f3 m\u00e1(\\w*)|(\\w*)c\u01b0\u1ee1ng hi\u1ebfp(\\w*)|(\\w*)\u0111\u00e9o(\\w*)|(\\w*)\u0111\u00e90(\\w*)|(\\w*)c\u1ee9t(\\w*)|(\\w*)v\u00e3i \u0111\u00e1i(\\w*)|(\\w*)bu\u1ed3i(\\w*)|(\\w*)l\u1ed3n(\\w*)|(\\w*)l\u00ecn(\\w*)|(\\w*)n\u1ed3n(\\w*)|(\\w*)v\u00e3i l\u00ecn(\\w*)|(\\w*)v\u00e3i l\u1ed3n(\\w*)|(\\w*)v\u00e3i n\u1ed3n(\\w*)|(\\w*)loo^`n(\\w*)|(\\w*)lo^`n(\\w*)|(\\w*)\u0111\u1ecbt(\\w*)|(\\w*)hi\u1ebfp(\\w*)|(\\w*)gi\u1ebft(\\w*)|(\\w*)vai lon(\\w*)|(\\w*)\u0111\u1ee5(\\w*)|(\\w*)c\u1eb7c(\\w*)|(\\w*)k\u1eb7c(\\w*)|(\\w*)d\u00e1i(\\w*)|(\\w*)Minh r\u00e2u(\\w*)|(\\w*)\u0111\u1ea3 \u0111\u1ea3o(\\w*)|(\\w*)t\u1ed5ng b\u00ed th\u01b0(\\w*)|(\\w*)ph\u1ea3n \u0111\u1ed9ng(\\w*)|(\\w*)nh\u00e2n quy\u1ec1n(\\w*)|(\\w*)H\u1ed3 Ch\u00f3 Minh(\\w*)|(\\w*)\u0111\u1ea3ng c\u01b0\u1edbp(\\w*)|(\\w*)Vi\u1ec7t C\u1ed9ng(\\w*)|(\\w*)Vi\u1ec7t gian(\\w*)|(\\w*)b\u1ed9 ch\u00ednh tr\u1ecb(\\w*)|(\\w*)PA25(\\w*)|(\\w*)\u0111\u1ed9c \u0111\u1ea3ng(\\w*)|(\\w*)\u0111a \u0111\u1ea3ng(\\w*)|(\\w*)\u0111\u01a1n \u0111\u1ea3ng(\\w*)|(\\w*)\u0111a nguy\u00ean(\\w*)|(\\w*)trung \u01b0\u01a1ng \u0110\u1ea3ng(\\w*)|(\\w*)k\u1ed9ng s\u1ea3n(\\w*)|(\\w*)c\u1ed9ng x\u1ea3n(\\w*)|(\\w*)c\u1ed9ngs\u1ea3n(\\w*)|(\\w*)cong san(\\w*)|(\\w*)nhan quyen(\\w*)|(\\w*)tu do ngon luan(\\w*)|(\\w*)tu do bao chi(\\w*)|(\\w*)b\u1ecd ch\u00ednh tr\u1ecb(\\w*)|(\\w*)b\u00f2 ch\u00ednh tr\u1ecb(\\w*)|(\\w*)Trung C\u1ed9ng(\\w*)|(\\w*)c\u01b0\u1edbp ch\u00ednh quy\u1ec1n(\\w*)|(\\w*)\u0111\u1ecbt con m\u1eb9(\\w*)|(\\w*)l\u1ed3n m\u1eb9(\\w*)|(\\w*)t\u1ed5 cha(\\w*)|(\\w*)ti\u00ean s\u01b0 b\u1ed1(\\w*)|(\\w*)c\u1ee9t th\u1eadt(\\w*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u0110\u1ed9(\\w*)|(\\w*)L\u00fd T\u1ed1ng(\\w*)|(\\w*)Ng\u00f4 Nh\u00e2n D\u1ee5ng(\\w*)|(\\w*)heroin(\\w*)|(\\w*)thu\u1ed1c phi\u1ec7n(\\w*)|(\\w*)serial number(\\w*)|(\\w*)crack(\\w*)|(\\w*)fucking(\\w*)|(\\w*)Ti\u00ean s\u01b0 cha(\\w*)|(\\w*)T\u1ed5 s\u01b0 b\u1ed1(\\w*)|(\\w*)fuck con m\u1eb9(\\w*)|(\\w*)v\u00e3i h\u00e0ng(\\w*)|(\\w*)k\u1ee9t(\\w*)|(\\w*)c-\u1ed9-n-g s-\u1ea3-n(\\w*)|(\\w*)thu\u1ed1c l\u1eafc(\\w*)|(\\w*)thu\u1ed1c phi\u1ec7n(\\w*)"; public static boolean foundProhibitedWords(String[] inputs) { if ((inputs == null) || (inputs.length == 0)) { return false; } return foundProhibitedWords(StringUtil.merge(inputs, StringPool.SPACE)); } public static boolean foundProhibitedWords(String input) { // There are some problems with this regular expression utility, so let // everything passes if (true) { return false; } if (Validator.isNull(input)) { return false; } RE r = null; try { r = new RE(prohibitedWords, RE.MATCH_CASEINDEPENDENT | RE.MATCH_MULTILINE); } catch (Exception e) { // ... } return (r == null) ? false : r.match(input); } }