{"action":"created","issue":{"url":"https://api.github.com/repos/dimagi/commcare-core/issues/405","repository_url":"https://api.github.com/repos/dimagi/commcare-core","labels_url":"https://api.github.com/repos/dimagi/commcare-core/issues/405/labels{/name}","comments_url":"https://api.github.com/repos/dimagi/commcare-core/issues/405/comments","events_url":"https://api.github.com/repos/dimagi/commcare-core/issues/405/events","html_url":"https://github.com/dimagi/commcare-core/pull/405","id":177514016,"number":405,"title":"Use safe double parse function","user":{"login":"wpride","id":2293064,"avatar_url":"https://avatars.githubusercontent.com/u/2293064?v=3","gravatar_id":"","url":"https://api.github.com/users/wpride","html_url":"https://github.com/wpride","followers_url":"https://api.github.com/users/wpride/followers","following_url":"https://api.github.com/users/wpride/following{/other_user}","gists_url":"https://api.github.com/users/wpride/gists{/gist_id}","starred_url":"https://api.github.com/users/wpride/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpride/subscriptions","organizations_url":"https://api.github.com/users/wpride/orgs","repos_url":"https://api.github.com/users/wpride/repos","events_url":"https://api.github.com/users/wpride/events{/privacy}","received_events_url":"https://api.github.com/users/wpride/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-16T20:30:38Z","updated_at":"2016-09-19T13:43:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-core/pulls/405","html_url":"https://github.com/dimagi/commcare-core/pull/405","diff_url":"https://github.com/dimagi/commcare-core/pull/405.diff","patch_url":"https://github.com/dimagi/commcare-core/pull/405.patch"},"body":"Fixes http://manage.dimagi.com/default.asp?237000\r\n\r\nThis is without a doubt the most obscure bug I've fixed in my lifetime. \r\n\r\nBasically way deep down in the XForm engine we have this code that attempts to parse as a double every string literal we process and, if successful, stores the value as in a CacheTable with the parsed double as the value and the string as a key. This includes things like fixture ID's that we use for indexing and later lookups. \r\n\r\nUnfortunately, until version 4.4 Android had a bug with the parseDouble function that you can read about here: https://android-review.googlesource.com/#/c/102376/. Because Java doubles use the exponential format MeP the \"e\" character could be in a valid double in certain circumstances. In the bug above case, the fixture ID was 1d9098a0c23a0c83740547dd946**e3783**\r\n\r\nSo, the bug would parse the trailing 946e3783 as a valid exponential with mantissa even though the rest of the string was complete garbage. This would evaluate to infinity (or Double.POSITIVE_INFINITY to be precise) and then be stored in the cache table as a valid double mapping.\r\n\r\nThen, all later lookups would use this value when trying to match against the filter expression in the XForm, which would of course fail.\r\n\r\nThis fix simply uses code from SO to parse the double and is the fastest possible (according to SO). Another smaller-touch fix would be to manually check for and reject the infinity value after parsing. \r\n\r\nThere's also a great post in Russian about the original discovery of the bug https://habrahabr.ru/post/234193/"},"comment":{"url":"https://api.github.com/repos/dimagi/commcare-core/issues/comments/247996670","html_url":"https://github.com/dimagi/commcare-core/pull/405#issuecomment-247996670","issue_url":"https://api.github.com/repos/dimagi/commcare-core/issues/405","id":247996670,"user":{"login":"wpride","id":2293064,"avatar_url":"https://avatars.githubusercontent.com/u/2293064?v=3","gravatar_id":"","url":"https://api.github.com/users/wpride","html_url":"https://github.com/wpride","followers_url":"https://api.github.com/users/wpride/followers","following_url":"https://api.github.com/users/wpride/following{/other_user}","gists_url":"https://api.github.com/users/wpride/gists{/gist_id}","starred_url":"https://api.github.com/users/wpride/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpride/subscriptions","organizations_url":"https://api.github.com/users/wpride/orgs","repos_url":"https://api.github.com/users/wpride/repos","events_url":"https://api.github.com/users/wpride/events{/privacy}","received_events_url":"https://api.github.com/users/wpride/received_events","type":"User","site_admin":false},"created_at":"2016-09-19T13:43:47Z","updated_at":"2016-09-19T13:43:47Z","body":"@amstone326 no Cory had confirmed it does not since it only affects one user\r\n"}}
{"actor":{"display_login":"wpride"}}