cbor 0.5.6.2 → 0.5.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95c5af13f98f6a6442e2a2b9c27ed4bdef1c5813
4
- data.tar.gz: 220ff8d73a25a32486e70a3ae863516193771661
3
+ metadata.gz: fbd9f75a0950815388c8f87da0acab19c6227e5a
4
+ data.tar.gz: 0d7d54f3811162926eff2af8d1a56a36ceaac85f
5
5
  SHA512:
6
- metadata.gz: e9ff567a84e861e9dea28e28465b14f5ce0bea61ebd5a964c57abb53dea6e7841d26e2396a98a8e97c0250336465b221f8b0f44709254b97d776859e904cb471
7
- data.tar.gz: 43bbd8691a9120b91385b1f0089fb3ee92d282b8ec2e63c617be1063e588849e2f84c57ad9425352c2263bf7d7cbe4fee4461b38957078784b2f0995b874cbd7
6
+ metadata.gz: a51ccc3cf050a569b3be7a80bdc848b04cd80b9a31338c485e0fce3277c1c7d2b37c21eebcbd054b11c8c911c81937c634bdd1acd3c7f82a1e15b9438957b8a1
7
+ data.tar.gz: 8c3a923d73a8539b576a8e63c8c5e7bf1b11f88b26386880e57af55a19c75b39bb18aa46ced3bd3583f2ea99032d210046731fbcc143d01fbc04b5711cb3dc7d
data/.gitignore CHANGED
@@ -3,7 +3,7 @@
3
3
  *.gem
4
4
  *.class
5
5
  .bundle
6
- Gemfile*
6
+ Gemfile.lock
7
7
  pkg
8
8
  test/debug.log
9
9
  *~
@@ -2,4 +2,12 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ # - rbx-19mode
6
+ - ruby-head
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: rbx-19mode # Rubinius issue #2742
5
10
  script: "bundle exec rake spec"
11
+
12
+ notifications:
13
+ irc: "irc.freenode.org#coap"
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2014-02-09 Carsten Bormann <cabo@tzi.org>
2
+
3
+ * 0.5.6.4: Add more checking for bare indefinite breaks and
4
+ non-strings inside indefinite strings.
5
+
1
6
  2013-08-17 Carsten Bormann <cabo@tzi.org>
2
7
 
3
8
  * First version of CBOR variant of this code.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "rake"
7
+ gem 'rake-compiler'
8
+ gem 'rspec'
9
+ gem 'json'
10
+ gem 'yard'
11
+ end
@@ -4,13 +4,21 @@ This is an initial Ruby implementation of the CBOR encoding, based on
4
4
  the (polished) high-performance msgpack-ruby code.
5
5
 
6
6
  Documentation will follow, but generally, if you replace MessagePack
7
- and msgpack with CBOR and cbor in the below, you will be on the right
8
- track.
7
+ and msgpack with CBOR and cbor in the text cited from MessagePack
8
+ below, you will be on the right track. For a starter:
9
+
10
+ require 'cbor'
11
+ s = [1, 2, 33.5, 4].to_cbor #=> "\x84\x01\x02\xF9P0\x04"
12
+ CBOR.decode(s) #=> [1, 2, 33.5, 4]
13
+
14
+ Use RubyGems to install:
15
+
16
+ gem install cbor
9
17
 
10
18
  CBOR is an object representation format defined by the IETF[http://ietf.org].
11
- The specification[http://tools.ietf.org/html/draft-bormann-cbor]
19
+ The specification[http://tools.ietf.org/html/rfc7049]
12
20
  has recently been approved as an IETF Standards-Track specification
13
- and will be an RFC in a couple of months, after the RFC editor has done their work.
21
+ and has been published as RFC 7049.
14
22
 
15
23
  This is all based on wonderful work by frsyuki, and I have no idea how
16
24
  to acknowledge him appropriately. This gem is not intended to fork or
@@ -25,12 +33,13 @@ Todos:
25
33
  percent slower than msgpack-ruby.
26
34
 
27
35
  * Properly document things, in particular the classes CBOR::Simple and
28
- CBOR::Tagged. If you check out the source, you can +rake doc+ to
36
+ CBOR::Tagged. If you check out the source, you can +rake+ +doc+ to
29
37
  get some documentation in the directory +doc+ (see +index.html+ there).
30
38
 
31
- * So far, this has been tested on MRI (1.9.3 and 2.0.0). To do:
32
- * Check this code out with Rubinius.
33
- * Publish the pure-ruby version and make it work the same way on JRuby.
39
+ * Cover more rubies.
40
+ * \[✔✔✔] tested on MRI (1.9.3, 2.0.0, 2.1.0-preview1).
41
+ * \[(✔)] tested on Rubinius 2.1.1. Mostly works, but runs into a few Rubinius bugs, which have since been fixed on the Rubinius side. Need to retest on the next release.
42
+ * \[_] Publish the pure-ruby version and make it work the same way on JRuby.
34
43
 
35
44
  * Find and implement good ways to offer CBOR's indefinite length
36
45
  ("streaming") capability at the Ruby API level.
@@ -47,7 +56,7 @@ Author:: Carsten Bormann <cabo@tzi.org>
47
56
  Copyright:: Copyright (c) 2013 Carsten Bormann
48
57
  License:: Apache License, Version 2.0
49
58
 
50
- {<img src="https://travis-ci.org/cabo/cbor-ruby.png?branch=master" />}[https://travis-ci.org/cabo/cbor-ruby]
59
+ {<img src="https://travis-ci.org/cabo/cbor-ruby.png?branch=master" />}[https://travis-ci.org/cabo/cbor-ruby] {<img src="https://badge.fury.io/rb/cbor.png" alt="Gem Version" />}[http://badge.fury.io/rb/cbor]
51
60
 
52
61
  For the original, see below.
53
62
 
@@ -583,6 +583,8 @@ int msgpack_unpacker_read(msgpack_unpacker_t* uk, size_t target_stack_depth)
583
583
  /* PRIMITIVE_OBJECT_COMPLETE */
584
584
 
585
585
  if(msgpack_unpacker_stack_is_empty(uk)) {
586
+ if (r == PRIMITIVE_BREAK)
587
+ return PRIMITIVE_INVALID_BYTE;
586
588
  return PRIMITIVE_OBJECT_COMPLETE;
587
589
  }
588
590
 
@@ -627,6 +629,8 @@ int msgpack_unpacker_read(msgpack_unpacker_t* uk, size_t target_stack_depth)
627
629
  object_complete_string(uk, top->object, top->count); /* use count as textflag */
628
630
  goto done;
629
631
  }
632
+ if (!RB_TYPE_P(uk->last_object, T_STRING))
633
+ return PRIMITIVE_INVALID_BYTE;
630
634
  #ifdef COMPAT_HAVE_ENCODING /* XXX */
631
635
  if (ENCODING_GET(top->object) != ENCODING_GET(uk->last_object))
632
636
  return PRIMITIVE_INVALID_BYTE;
@@ -1,3 +1,3 @@
1
1
  module CBOR
2
- VERSION = "0.5.6.2"
2
+ VERSION = "0.5.6.4"
3
3
  end
@@ -342,13 +342,31 @@ describe MessagePack do
342
342
  end
343
343
  end
344
344
 
345
+ it "(_ not-a-string)" do
346
+ lambda {
347
+ check_decode "\x5f\x00\xff", "".b
348
+ }.should raise_error(MessagePack::MalformedFormatError)
349
+ end
350
+
351
+ it "bare break" do
352
+ lambda {
353
+ check_decode "\xff", "".b
354
+ }.should raise_error(MessagePack::MalformedFormatError)
355
+ lambda {
356
+ check_decode "\x82\xff\x00\x00", "".b
357
+ }.should raise_error(MessagePack::MalformedFormatError)
358
+ lambda {
359
+ check_decode "\x82\x9f\xff\xff", "".b
360
+ }.should raise_error(MessagePack::MalformedFormatError)
361
+ end
362
+
345
363
  it "Time" do
346
364
  check_decode "\xc1\x19\x12\x67", Time.at(4711)
347
365
  check 6, Time.at(Time.now.to_i)
348
366
  end
349
367
 
350
368
  it "URI" do
351
- check_decode "\xd8\x20\x78\x13http://www.ietf.org", CBOR::Tagged.new(32, "http://www.ietf.org")
369
+ # check_decode "\xd8\x20\x78\x13http://www.ietf.org", CBOR::Tagged.new(32, "http://www.ietf.org")
352
370
  require 'uri'
353
371
  check_decode "\xd8\x20\x78\x13http://www.ietf.org", URI.parse("http://www.ietf.org")
354
372
  # This doesn't work yet if 'uri' is not required before 'cbor':
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6.2
4
+ version: 0.5.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann, standing on the tall shoulders of Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-27 00:00:00.000000000 Z
11
+ date: 2014-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler