Hi again, the attachment no contains the same patch, but created using "diff -Naur" command:
diff -Naur
turbine-unchanged/turbine-2.3.2/src/java/org/apache/turbine/services/intake/validator/StringValidator.java
turbine-2.3.2-JV-20060109/turbine-2.3.2/src/java/org/apache/turbine/services/intake/validator/StringValidator.java
> StringValidator.java.JV-20060109.patch
also patch to project.properties which changes rependency to JDK1.4 attached
Jindrich Vimr
Jindrich Vimr wrote:
> Hi,
>
> for our turbine-based application we started use intake for form fields
> validation. Our customers use non-Latin charsets for data entered into
> form fields, but we were unable to validate them using intake.
> Intake currently uses ORO for regexp validation, but ORO doesn't handle
> the unicode perl5 regexps (like \\p{L} for Letters in any encoding, not
> only A-Za-z).
> The sun's java.util.regexp. package these unicode regexps implement, so
> I decided to rewrite the StringValidator in intake to use
> java.util.regexp classes instead of ORO. The patch against turbine-2.3.2
> is attached bellow. We test this patch internally, but for now it seems
> to work OK. This way turbine is able to handle unicode inputs checked by
> intake.
> If someone has some complains about choosing sun's java.util.regexp for
> this patch, drop me a note. The only downside of choosing
> java.util.regexp is the dependency on JDK1.4 or higher.
>
>
>
> Jindrich Vimr
>
> the patch:
--
Jindrich Vimr <[EMAIL PROTECTED]>
HSF Sokolov, spol. s r.o. +420 724 293 903
Morseova 3, Plzen http://www.hsf.cz
GPG public key: http://shop.hsf.cz/gpg/vimr/gpgpubkey-vimr_at_hsf.cz.gpg
--- turbine-unchanged/turbine-2.3.2/project.properties 2005-10-03 14:52:31.000000000 +0200
+++ turbine-2.3.2-JV-20060109/turbine-2.3.2/project.properties 2006-01-10 13:13:08.806672376 +0100
@@ -49,8 +49,8 @@
# Display the version the web site is documenting
maven.xdoc.version = ${pom.currentVersion}
-maven.compile.source = 1.3
-maven.compile.target = 1.3
+maven.compile.source = 1.4
+maven.compile.target = 1.4
maven.compile.debug = on
maven.compile.optimize = off
maven.compile.deprecation = off
--- turbine-unchanged/turbine-2.3.2/src/java/org/apache/turbine/services/intake/validator/StringValidator.java 2005-10-03 14:52:35.000000000 +0200
+++ turbine-2.3.2-JV-20060109/turbine-2.3.2/src/java/org/apache/turbine/services/intake/validator/StringValidator.java 2006-01-10 12:18:31.641877152 +0100
@@ -17,13 +17,12 @@
*/
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import org.apache.commons.lang.StringUtils;
-import org.apache.oro.text.regex.MalformedPatternException;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
/**
* A validator that will compare a testValue against the following
@@ -41,6 +40,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Quinton McCombs</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Colin Chalmers</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Jindrich Vimr HSF.cz</a> - patch to use java.util.regexp
* @version $Id: StringValidator.java 264148 2005-08-29 14:21:04Z henning $
*/
public class StringValidator
@@ -49,7 +49,7 @@
/** The matching mask String as supplied by the XML input */
protected String maskString = null;
- /** The compiled perl5 Regular expression from the ORO Perl5Compiler */
+ /** The compiled perl5 Regular expression from the java.util.regexp.Pattern */
protected Pattern maskPattern = null;
/** The message to report if the mask constraint is not satisfied */
@@ -139,11 +139,11 @@
{
if (maskPattern != null)
{
- /** perl5 matcher */
- Perl5Matcher patternMatcher = new Perl5Matcher();
+ /** java.util.regexp.Matcher */
+ Matcher patternMatcher = maskPattern.matcher(testValue);
boolean patternMatch =
- patternMatcher.matches(testValue, maskPattern);
+ patternMatcher.matches();
log.debug("Trying to match " + testValue
+ " to pattern " + maskString);
@@ -181,19 +181,18 @@
throws InvalidMaskException
{
/** perl5 compiler, needed for setting up the masks */
- Perl5Compiler patternCompiler = new Perl5Compiler();
maskString = mask;
// Fixme. We should make this configureable by the XML file -- hps
- int maskOptions = Perl5Compiler.DEFAULT_MASK;
+ //int maskOptions = Perl5Compiler.DEFAULT_MASK;
try
{
log.debug("Compiling pattern " + maskString);
- maskPattern = patternCompiler.compile(maskString, maskOptions);
+ maskPattern = Pattern.compile(maskString);
}
- catch (MalformedPatternException mpe)
+ catch (PatternSyntaxException mpe)
{
throw new InvalidMaskException("Could not compile pattern " + maskString, mpe);
}
signature.asc
Description: OpenPGP digital signature
