cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-11223) Better check for date validity of contact.birthday / Fix: RangeError Invalid Date
Date Fri, 06 May 2016 20:56:12 GMT

    [ https://issues.apache.org/jira/browse/CB-11223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15274718#comment-15274718
] 

ASF GitHub Bot commented on CB-11223:
-------------------------------------

GitHub user TanaseButcaru opened a pull request:

    https://github.com/apache/cordova-plugin-contacts/pull/125

    [CB-11223] Better check for date validity of contact.birthday / Fix: RangeError Invalid
Date

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/TanaseButcaru/cordova-plugin-contacts master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-contacts/pull/125.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #125
    
----
commit 225bfcbaff0bc0d62fd4a557df1761338debcb90
Author: TanaseButcaru <contact@butcaru.com>
Date:   2016-05-06T20:08:40Z

    handle 'Invalid Date' error

----


> Better check for date validity of contact.birthday / Fix: RangeError Invalid Date
> ---------------------------------------------------------------------------------
>
>                 Key: CB-11223
>                 URL: https://issues.apache.org/jira/browse/CB-11223
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: Plugin Contacts
>         Environment: Desktop Firefox & Safari
> Android & iOS Webview
>            Reporter: Tanase Butcaru
>            Priority: Critical
>              Labels: easyfix
>
> The issue: on Safari & iOS webview if we perform a _toJSON()_ on a instanceof Date
object which is a 'Invalid Date' object, that throws an error. This does not happen on Firefox
& Chrome!
> I encountered this issue while sending device contacts over _socket.io_ which iterates
over contacts props and does a _toJSON()_, but the problem was that the Date object from _birthday_
property was not valid.
> Simple test case:
> {code:javascript}
> var contact = { birthday: null }; //data provided by cordova-plugin-contacts
> try {
>     contact.birthday = new Date(parseFloat(contact.birthday));
> }
> catch(e) {
>    console.log(e); //this will never be called
> }
> //where the error occures..
> contact.birthday.toJSON();
> {code}
> An 'Invalid Date' error does not throw anything, so a simple try-catch block doesn't
pass the validity of that date.
> The changes I made in _convertUtils.js_ resolves this problem.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message