Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix null handling with base64 encoded data

  • Loading branch information...
commit fc3086fceab75f23b4be5db095f971aa80fb98c7 1 parent 1c953c6
Karsten Dambekalns authored
2  lib/Doctrine/DBAL/Types/ArrayType.php
View
@@ -46,7 +46,7 @@ public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatf
$value = (is_resource($value)) ? stream_get_contents($value) : $value;
// check for base64 encoded serialized data
- if (strpos($value, ':') !== 1) {
+ if (strpos($value, ':') !== 1 && strpos($value, ';') !== 1) {
$value = base64_decode($value);
}
$val = unserialize($value);
2  lib/Doctrine/DBAL/Types/ObjectType.php
View
@@ -46,7 +46,7 @@ public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatf
$value = (is_resource($value)) ? stream_get_contents($value) : $value;
// check for base64 encoded serialized data
- if (strpos($value, ':') !== 1) {
+ if (strpos($value, ':') !== 1 && strpos($value, ';') !== 1) {
$value = base64_decode($value);
}
$val = unserialize($value);
12 tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
View
@@ -53,11 +53,21 @@ public function testConversionFailure()
$this->_type->convertToPHPValue('abcdefg', $this->_platform);
}
- public function testNullConversion()
+ public function testPlainNullConversion()
{
$this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
}
+ public function testNullConversion()
+ {
+ $this->assertNull($this->_type->convertToPHPValue(serialize(null), $this->_platform));
+ }
+
+ public function testNullConversionForBase64()
+ {
+ $this->assertNull($this->_type->convertToPHPValue(base64_encode(serialize(null)), $this->_platform));
+ }
+
/**
* @group DBAL-73
*/
12 tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
View
@@ -46,11 +46,21 @@ public function testConversionFailure()
$this->_type->convertToPHPValue('abcdefg', $this->_platform);
}
- public function testNullConversion()
+ public function testPlainNullConversion()
{
$this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
}
+ public function testNullConversion()
+ {
+ $this->assertNull($this->_type->convertToPHPValue(serialize(null), $this->_platform));
+ }
+
+ public function testNullConversionForBase64()
+ {
+ $this->assertNull($this->_type->convertToPHPValue(base64_encode(serialize(null)), $this->_platform));
+ }
+
/**
* @group DBAL-73
*/
Please sign in to comment.
Something went wrong with that request. Please try again.