Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7D3B6200AC6 for ; Fri, 6 May 2016 23:42:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7C11D1608F8; Fri, 6 May 2016 21:42:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CCDA5160A0C for ; Fri, 6 May 2016 23:42:13 +0200 (CEST) Received: (qmail 36377 invoked by uid 500); 6 May 2016 21:42:13 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 36304 invoked by uid 99); 6 May 2016 21:42:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 May 2016 21:42:12 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id DA6BD2C1F5C for ; Fri, 6 May 2016 21:42:12 +0000 (UTC) Date: Fri, 6 May 2016 21:42:12 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-11223) Better check for date validity of contact.birthday / Fix: RangeError Invalid Date MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 06 May 2016 21:42:14 -0000 [ https://issues.apache.org/jira/browse/CB-11223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15274777#comment-15274777 ] ASF GitHub Bot commented on CB-11223: ------------------------------------- Github user omefire commented on the pull request: https://github.com/apache/cordova-plugin-contacts/pull/125#issuecomment-217565470 Do you know why is iOS setting an 'Invalid Date' in the first place ? I feel like this fix might end up just masking an issue on the native side. > 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