2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 2.00 of the Zend license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.zend.com/license/2_00.txt. |
12 | If you did not receive a copy of the Zend license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@zend.com so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #include "hphp/runtime/base/variable_unserializer.h"
19 #include "hphp/runtime/base/complex_types.h"
20 #include "hphp/runtime/base/zend-strtod.h"
21 #include "hphp/runtime/base/array_iterator.h"
22 #include "hphp/runtime/ext/ext_class.h"
25 ///////////////////////////////////////////////////////////////////////////////
27 Variant
VariableUnserializer::unserialize() {
33 Variant
VariableUnserializer::unserializeKey() {
35 v
.unserialize(this, Uns::Mode::Key
);
39 int64_t VariableUnserializer::readInt() {
42 int64_t r
= strtoll(m_buf
, &newBuf
, 10);
47 double VariableUnserializer::readDouble() {
50 double r
= zend_strtod(m_buf
, &newBuf
);
55 void VariableUnserializer::read(char *buf
, uint n
) {
58 /* compute copy boundaries in a more efficient manner,
59 by using min(...) operation rather than complex conditional
61 const size_t BUFFER_SIZE
= m_end
- m_buf
;
62 const size_t BUFFER_LIMIT
= std::min(BUFFER_SIZE
, size_t(n
));
64 memcpy(buf
, m_buf
, BUFFER_LIMIT
);
65 m_buf
+= BUFFER_LIMIT
;
68 Variant
&VariableUnserializer::addVar() {
69 m_vars
.push_back(uninit_null());
73 bool VariableUnserializer::isWhitelistedClass(CStrRef cls_name
) const {
74 if (m_type
!= Type::Serialize
|| m_classWhiteList
.isNull()) {
77 if (!m_classWhiteList
.isNull() && !m_classWhiteList
.empty()) {
78 for (ArrayIter
iter(m_classWhiteList
); iter
; ++iter
) {
79 CVarRef
value(iter
.secondRef());
80 if (f_is_subclass_of(cls_name
, value
.toString()) ||
81 same(value
, cls_name
)) {
89 ///////////////////////////////////////////////////////////////////////////////