Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions msgpack/pack_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,10 @@ msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
if(l < 32) {
unsigned char d = 0xa0 | l;
msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
} else if (l < 256) {
unsigned char buf[2];
buf[0] = 0xd9; buf[1] = (uint8_t)l;
msgpack_pack_append_buffer(x, buf, 2);
} else if(l < 65536) {
unsigned char buf[3];
buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
Expand Down
1 change: 1 addition & 0 deletions msgpack/unpack_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef enum {
//CS_BIG_INT_32 = 0x17,
//CS_BIG_FLOAT_16 = 0x18,
//CS_BIG_FLOAT_32 = 0x19,
CS_RAW_8 = 0x19,
CS_RAW_16 = 0x1a,
CS_RAW_32 = 0x1b,
CS_ARRAY_16 = 0x1c,
Expand Down
6 changes: 6 additions & 0 deletions msgpack/unpack_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
//case 0xd7: // big integer 32
//case 0xd8: // big float 16
//case 0xd9: // big float 32
case 0xd9:
trail = *(++p);
p++;
n = p; p += trail - 1;
cs = CS_RAW_8;
goto _raw_zero;
case 0xda: // raw 16
case 0xdb: // raw 32
case 0xdc: // array 16
Expand Down
27 changes: 27 additions & 0 deletions tests/137.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
unpack/pack str8
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
function test() {
if(!extension_loaded('msgpack'))
{
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}

$str = "Simple test for short string - type str8";
$str8 = chr(0xD9) . chr(strlen($str)) . $str;
echo msgpack_unpack($str8) . "\n";
$data = msgpack_pack($str);
echo ($data[0] == chr(0xD9) && $data[1] == chr(strlen($str)) ? "OK" : "FAILED"), PHP_EOL;
}

test();
?>
--EXPECTF--
Simple test for short string - type str8
OK