[hibernate-issues] [Hibernate-JIRA] Commented: (HV-376) validateValue() and validateProperty() are too restrictive regarding processable property names

Kevin Pollet (JIRA) noreply at atlassian.com
Mon Feb 7 09:46:05 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-376?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39854#action_39854 ] 

Kevin Pollet commented on HV-376:
---------------------------------

I've an other proposition to avoid the use of categories pattern in the regular expression. The regular expression could be modified to

{code}private static final Pattern PATH_PATTERN = Pattern.compile( "([^\\[\\.]+)(\\[(\\w*)\\])?(\\.(.*))*" );{code}

and add a method in the PathImpl class which validates the identifier with the *Character* _isJavaIdentifierStart/Part_ methods. Something like this [https://gist.github.com/3e1da7b7f3660868cba5].

WDYT ?

> validateValue() and validateProperty() are too restrictive regarding processable property names
> -----------------------------------------------------------------------------------------------
>
>                 Key: HV-376
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-376
>             Project: Hibernate Validator
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 4.1.0.Final
>            Reporter: Gunnar Morling
>            Assignee: Kevin Pollet
>            Priority: Minor
>             Fix For: 4.2.0.CR1
>
>
> The methods Validator#validateValue() and Validator#validateProperty() expect the name of a bean property, for which constraint validation should be performed.
> Currently not all valid Java property (field/method) identifiers are supported here, as the specified property name is processed in PathImpl with a regular expression, that matches only the word character class (A-Za-z0-9_), causing the evaluation of uncommon but yet valid property names such as the following ones to fail:
> * private String höchstBetrag; // German Umlaute such as "ö" are allowed in Java identifiers
> * private String €Amount;  // some currency signs such as "€" are allowed, sigh
> * private String höchst\u00f6Betrag; // specifying letters such as "ö" using Unicode is allowed
> Trying to do so results in the following exception:
> {code:java} 
> java.lang.IllegalArgumentException: Unable to parse property path ö
> at org.hibernate.validator.engine.PathImpl.parseProperty(PathImpl.java:216)
> at org.hibernate.validator.engine.PathImpl.createPathFromString(PathImpl.java:64)
> at org.hibernate.validator.engine.ValidatorImpl.validateValue(ValidatorImpl.java:152)
> {code} 
> More information on the identifiers allowed in the Java language can be found in [JLS, chapter 3.8|http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8].

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list