Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ISO8601 Crashes #586

Closed
phoney opened this issue Sep 6, 2018 · 8 comments
Closed

Fixed ISO8601 Crashes #586

phoney opened this issue Sep 6, 2018 · 8 comments
Assignees
Labels
Milestone

Comments

@phoney
Copy link

phoney commented Sep 6, 2018

I'm getting a crash when parsing ISO dates of the form "2018-08-01" on iOS 12 using Xcode beta 6 on the simulator.

Simply adding this line to applicationdidFinishLaunching causes the crash:

let date = ISOParser.date(from: "2017-01-03")

The crash is a "String index is out of bounds" error inside the current() method.

Parsing longer ISO dates works as expected. I haven't updated the code to swift 4.2. Swift version is set to 4. SwiftDate is 5.0.7 and is installed with CocoaPods.

Parsing dateStrings like this has always worked fine on iOS 11 and earlier.

@muukii
Copy link
Contributor

muukii commented Sep 13, 2018

I have the same issue.

@phoney
Copy link
Author

phoney commented Sep 13, 2018

Apparently any deviation from the required ISO format is likely to cause this crash. I had a string in a unit test that was missing the trailing Z and that crashed. Obviously something has changed. These dates were accepted previously. If the intent is for them to not be accepted ISOParser should still not crash. It's supposed to return nil.

My workaround for my short dates "2018-08-01" has been to use a DateParser with the matching format.

@ntokozo-online
Copy link

Having the same issue on the Xcode 10 GM seed. Does anyone have idea on when this will be resolved?

@malcommac malcommac changed the title Xcode 10 beta 6 iOS 12 ISOParser Crash Fixed ISO8601 Crashes Sep 18, 2018
@malcommac
Copy link
Owner

This is not related to XCode 10 but it's a bug of the parser. Fixed it and added several other unit tests.

@malcommac malcommac self-assigned this Sep 18, 2018
@malcommac malcommac added the bug label Sep 18, 2018
@malcommac malcommac added this to the 5.0.9 milestone Sep 18, 2018
@redent
Copy link

redent commented Oct 8, 2018

Are you releasing this fix to 4.x or is it a dead branch?

raudabaugh pushed a commit to raudabaugh/SwiftDate that referenced this issue Oct 13, 2018
@raudabaugh
Copy link

raudabaugh commented Oct 13, 2018

Hey @redent, I cherrypicked the fix onto latest 4.x and it fixed my issues. (link to commit above)

@malcommac would you consider accepting a PR for this? I imagine there are a decent number of us still on Swift 3.x that need iOS 12 support

@MrMatthewDavis
Copy link

@malcommac Any update on whether or not this change could be PR'd into a 4.x branch? Our project relies heavily on SwiftDate and upgrading to 5.x is not something we can do right now.

@migeleinc
Copy link

@malcommac Similar to @MrMatthewDavis and @raudabaugh we'd like to ask this fix retrofitted to 4.x if at all possible - for reasons articulated by MrMatthewDavis.

SwiftDate 4.3.0 and ISO8601Parser with a date string composed of a year and a week number (e.g. "2019-W13") appears also to crash, please see an example below:
let date = ISO8601Parser.date(from: "2019-W13")?.date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants