[
https://issues.apache.org/jira/browse/TRINIDAD-1537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Matthias Weßendorf updated TRINIDAD-1537:
-----------------------------------------
Resolution: Fixed
Fix Version/s: 1.2.12-core
Assignee: Matthias Weßendorf
Status: Resolved (was: Patch Available)
> client convertNumber truncates invalid number instead of throwing exception
> ---------------------------------------------------------------------------
>
> Key: TRINIDAD-1537
> URL: https://issues.apache.org/jira/browse/TRINIDAD-1537
> Project: MyFaces Trinidad
> Issue Type: Bug
> Reporter: Cale Scholl
> Assignee: Matthias Weßendorf
> Fix For: 1.2.12-core
>
> Attachments: 1.2.11.4-branch_strictNumberParse.patch,
> trunk_strictNumberParse.patch
>
>
> On the client, 123abc45 is truncated to 123, whereas it should throw an
> exception; the server throws an exception
> The reason that 123abc45 is truncated to 123 is due to a native js function:
> parseFloat("123abc45") returns 123.
> For currency and percent, the number string is parsed using an instance of
> NumberFormat, which calls parseFloat on the number string.
> However, for the number type, _decimalParse applies some "js magic" before
> calling parseFloat:
> // OK; it's non-empty. Now, disallow exponential
> // notation, and then use some JS magic to exclude
> // non-numbers
> if ((numberString.indexOf('e') < 0) &&
> (numberString.indexOf('E') < 0) &&
> (((numberString * numberString) == 0) ||
> ((numberString / numberString) == 1)))
> So if we want to rule out number strings like "123abc45" for currency and
> percent, we simply need to apply the same "js magic" to the parsing functions
> in NumberFormat:
> TrNumberFormat.prototype.stringToNumber
> TrNumberFormat.prototype.stringToCurrency
> TrNumberFormat.prototype.stringToPercentage
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.