Commit Graph
405 Commits
Author SHA1 Message Date
James Coglan cee5700a02 Catch errors with close frames with invalid UTF-8. 2016-12-29 02:10:51 +00:00
James Coglan 21bfd23f1a Implement basic RSV checking for the case when no extensions are active. 2016-12-29 01:55:23 +00:00
James Coglan 6ffb801dd1 Remove a redundant check for continuation frames when there's no initialised message. 2016-12-29 01:54:54 +00:00
James Coglan fb8fcfa5f1 Run the Hybi specs against both the pure-Ruby and the native versions of the driver. 2016-12-29 01:09:12 +00:00
James Coglan 97b497a520 Drop the old native extension and replace it with the new all-C parser. Replace the old masking code with a Ruby version, so that the Hybi class is pure Ruby. 2016-12-29 01:09:12 +00:00
James Coglan 0eb64913ca Capture errors raise by emit() and re-raise them after the parser has finished running. 2016-12-29 00:56:55 +00:00
James Coglan 524aa3f356 Add handling of close frames. 2016-12-29 00:34:36 +00:00
James Coglan 8eaae3a149 Implement hooks for ping/pong. 2016-12-28 18:04:27 +00:00
James Coglan 78c5aea489 Check for valid UTF-8 after the message has gone through extensions, e.g. a deflate-encoded payload will not be valid UTF-8. 2016-12-28 16:35:45 +00:00
James Coglan ce21d26e48 Check the length of incoming frames, including checking what they would add to the total message size. 2016-12-28 16:35:05 +00:00
James Coglan 721644495b Implement the require_masking flag properly. 2016-12-28 16:14:52 +00:00
James Coglan d6ddd6eedc Implement some error handling: checking for non-final and too-long control frames, unmasked data, and continuation violations. 2016-12-28 15:59:25 +00:00
James Coglan ae62fc6322 Begin emitting native parser errors back to the driver, starting by handling invalid opcodes. 2016-12-28 15:25:44 +00:00
James Coglan fbd22b99aa Make wsd_Queue_destroy() for-loop simpler and remove an unused variable warning. 2016-12-27 14:54:18 +00:00
James Coglan 8366d2790a Move declarations to the top of WebSocketParser callbacks. 2016-12-27 14:50:22 +00:00
James Coglan 01e8bd904d Wrap calls out to the Ruby driver and user callbacks in rb_protect. 2016-12-27 14:39:01 +00:00
James Coglan 4e747733a3 Begin wiring the C parser up to a Ruby driver. Driver::Native is currently a hollowed-out copy of Driver::Hybi with the parsing code removed. 2016-12-27 12:26:59 +00:00
James Coglan d5b2af3782 Make the Observer and Parser structs opaque. 2016-12-26 16:38:37 +00:00
James Coglan abd0a9372c Make the Queue structs opaque. 2016-12-26 15:59:31 +00:00
James Coglan 94317d4461 Make the ReadBuffer structs opaque. 2016-12-26 15:17:05 +00:00
James Coglan 4a79ae4eea Remove a couple of demeter violations: the parser accessing buffer->capacity, and buffer reaching into its queue via queue->head->value. 2016-12-26 12:55:46 +00:00
James Coglan 10f180e9f1 Use a macro for freeing then nulling a pointer, and make sure all destructors null out pointers where appropriate. 2016-12-26 12:14:51 +00:00
James Coglan fd4bbb0c12 Don't check if pointers are not NULL before freeing them.
Freeing a null pointer is a no-op and doesn't stop you double-freeing
things. What actually stops that is nulling out pointers after you've
freed what they point at.
2016-12-24 12:02:10 +00:00
James Coglan 5f1a789e3b Null out member pointers after freeing them in destroy() functions. 2016-12-24 11:02:00 +00:00
James Coglan 75ccaa2e2a Make the benchmark frame generator work on 1.9. 2016-12-24 02:03:03 +00:00
James Coglan 29321d3867 The 'masking' field of wsd_Parser is not needed; it's a serialisation setting not a parsing one. 2016-12-24 00:34:16 +00:00
James Coglan 67de925527 Define _GNU_SOURCE in parser.c rather than parser.h to fix asprintf() warning (thanks @mjg59). 2016-12-23 23:25:20 +00:00
James Coglan 285a14d4cc Put the on_frame callback at the end of websocket_parser.c. 2016-12-23 23:22:52 +00:00
James Coglan 430ae06161 Use PRIu64 to print uint64_t. 2016-12-23 23:05:02 +00:00
James Coglan 87f93d2d6a define _GNU_SOURCE to silence warnings about asprintf. 2016-12-23 22:56:56 +00:00
James Coglan a269b58d09 Wrap wsd_Queue_each in braces to prevent 'C90 forbids mixed declarations and code' warnings. 2016-12-23 22:34:42 +00:00
James Coglan 51da1913ac Deal with most of the C90 'forbids mixed declarations and code' warnings. 2016-12-23 22:24:29 +00:00
James Coglan a6db9856b1 Include stdint.h to see if it fixes the build on Travis. 2016-12-23 21:58:50 +00:00
James Coglan 8d1792941f Introduce the Observer type for adding callbacks into the parser. 2016-12-23 21:54:55 +00:00
James Coglan 5e23116c6e Split the C parser up into multiple files, one per 'class'. 2016-12-23 21:22:21 +00:00
James Coglan 4772f71114 Put in more checks to the C parser to make sure each bit of the parser works, and begin putting in parser error handling. 2016-12-23 20:58:24 +00:00
James Coglan 11349c56b7 Queue.tail should be set to NULL if the current count is 1; count is not decremented until the end of the function. 2016-12-23 08:49:00 +00:00
James Coglan a4ed6af167 Align names of forward declarations; it makes them easier for me to read. 2016-12-23 08:46:45 +00:00
James Coglan 2e6d2b070d Begin a minimum-viable parser in C. 2016-12-22 21:10:33 +00:00
James Coglan 568dc364a8 Bump Ruby versions 2.2 and 2.3 on Travis. 2016-11-21 23:22:52 +00:00
James Coglan 58cdc2305b Remove Rubinius from the build as it hasn't worked on Travis for weeks. 2016-10-26 09:14:02 +01:00
James Coglan 930bbe2020 Move the license text into a separate file. 2016-07-19 20:57:38 +01:00
James Coglan 673d11e436 Bump version to 0.6.4. 0.6.4 2016-05-20 08:46:06 +01:00
James Coglan 9ce857b3d4 Revise uses of encoding APIs.
When originally implemented, we still supported Ruby 1.8, which
necessitated checking for encoding methods and using a regex to validate
UTF-8. These checks are now gone.

We tagged many strings as binary when not strictly necessary, either
because we were just going to iterate their bytes or because we were
going to hand them off to the caller which should just write them
directly to a socket. Strings used as buffers to accumulate streaming
input are still tagged as binary to avoid encoding
collision/conversion.

The places where we do need to tag as UTF-8 (i.e. just before emitting
to the application) remain, but copy the string if necessary. This
allows us to work with frozen strings.

Finally, strings passed in via the Driver#text method should be
*transcoded* to UTF-8 if necessary, not merely tagged. The Ruby
String#encode method produces a new string so this should also be safe
with frozen strings.
2016-05-19 21:08:22 +01:00
James Coglan 115d82bebb Silence all -W2 warnings. 2016-05-18 22:42:16 +01:00
James Coglan 15ba7410c6 Remove some unused variables from Hybi#send_frame. 2016-05-18 22:33:33 +01:00
James Coglan ca9faf0ff4 Update Ruby versions for Travis. 2016-04-30 13:10:29 +01:00
James Coglan 188b7d897e Create CODE_OF_CONDUCT.md. 2015-11-08 12:16:43 +00:00
James Coglan d515dc0894 Bump version to 0.6.3. 0.6.3 2015-11-06 22:24:35 +00:00
James Coglan 4ae198b1d3 Throw a more helpful error if a client driver is created with an invalid URL. 2015-10-17 21:37:13 +01:00