-
Notifications
You must be signed in to change notification settings - Fork 827
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
Allow . to match any character, including line separators. #11
Comments
@hanishabsigh can you provide a message that fails to get parsed. You can uncomment https://github.com/socketio/socket.io-client-swift/blob/master/SwiftIO/SocketEngine.swift#L409 to see messages before they get sent to the socket.io-client parser. |
I'm actually finding a few problems with regex. Mostly due to the differences between NSString and String. |
My object that fails is very large, here is an example I was able to track down: The following fails:
The following succeeds:
The line break in the message of the day causes the parsing of the groups to break. |
@nuclearace I just noticed you made some parsing changes, this was tested prior to those changes, thanks |
@hanishabsigh It seems to work for me on the latest. Please note #13 though. Since it can cause the regex to fail sometimes. Which is why I changed some things. |
@nuclearace This still isn't working for me, incoming messages can't even get passed the following line:
Replacing line 224 with the following worked:
|
@hanishabsigh try after 44e2781 |
@nuclearace Checking against the latest commit isn't working, something about the changes in SwiftRegex. So far from what I can tell regex.firstMatchInString in the groups method isn't returning anything. Still investigating. Thanks |
This client is able to get this for me: socket.emit("jsonTest", {foo: "string\ntest test"}) |
Ok, fixed it by changing the following:
To this:
I think the error I was experiencing was happening because my json had variable-width Unicode characters. Found someone having the same issues with swift on StackOverflow: http://stackoverflow.com/questions/25882503/how-can-i-use-nsregularexpression-on-swift-strings-with-variable-width-unicode-c |
@hanishabsigh so does c67e7a3 fix it |
@nuclearace Yes, that commit fixes it, thanks. |
|
First...thank you for this library. I was experiencing an issue in which a large incoming event wasn't being passed to the appropriate on: handler. No error was thrown. After some investigation, I narrowed it down to regex operations that weren't outputting valid json, thus leading the NSJSONSerialization to fail. Here is an example of the regex, although it happens a few times within the library:
The end of the regex uses a . to match any character, but by default it does not match line separators. If the intent is to include them, SwiftRegex lets us set the option NSRegularExpressionOptions.DotMatchesLineSeparators. I attempted a pull request to do the following but it wasn't working for me:
I must be missing something, I thought that subscript would work but it crashes for me. The following did work:
Also, it could be helpful to include a warning when the event parsing fails. Thanks!
The text was updated successfully, but these errors were encountered: