tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thiago H. de Paula Figueiredo (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (TAP5-1998) DateField does not validate dates properly
Date Fri, 03 Jan 2014 19:45:51 GMT

     [ https://issues.apache.org/jira/browse/TAP5-1998?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thiago H. de Paula Figueiredo resolved TAP5-1998.
-------------------------------------------------

       Resolution: Fixed
    Fix Version/s: 5.4

> DateField does not validate dates properly
> ------------------------------------------
>
>                 Key: TAP5-1998
>                 URL: https://issues.apache.org/jira/browse/TAP5-1998
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Barry Books
>            Assignee: Thiago H. de Paula Figueiredo
>            Priority: Minor
>              Labels: month-of-tapestry, patch
>             Fix For: 5.4
>
>
> Due to the way the Java DateFormat class works there are 2 cases that allow invalid dates
threw the DateField component.
> 1. By default date parsing is lenient. This means dates such as 00/01/2000 are converted
to 12/01/1999 and passed thru. There is no way for the application to know this has happened.
> 2. The DateFormat class ignores trailing characters. This means an input of 01/01/200-
will result in a date of 01/01/200 again there is no way for the application to know this
has happened.
> It's possible to work around both these issues but I think the workarounds are not obvious
and in practice difficult to implement. To work around the first problem you can pass a DateFormat
with lenient set to false. The service that converts Strings to DateFormat does not do this
and it does not seem possible to override it so all the DateFormats much be created in Java
code. The second issue can be resolved by providing a regexp expression to validate the date.
For some date formats  such as MM/dd/yyyy this is pretty easy but other date formats are complex
and it's difficult to come up with a correct regular expression.
> So I would like to propose changing DateField to set lenient to false and use parse(source,pos)
instead of paste(source). This change is not strictly backward compatible and a parameter
could be added that allows the old behavior. My guess is there are not many people depending
on the existing behavior  since it really allows invalid dates to be silently input.
> I have a patch that I can contribute.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message