Skip to content

Commit 97b80fb

Browse files
authored
Merge pull request #251 from mikehaertl/249-fix-null-values
Issue #249 Fix infinite loop with null values in form data
2 parents 8a6fe16 + 31e5ec6 commit 97b80fb

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/XfdfFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function writeFields($fp, $fields)
184184
if (!is_array($value)) {
185185
$value = array($value);
186186
}
187-
if (isset($value[0])) {
187+
if (array_key_exists(0, $value)) {
188188
// Numeric keys: single or multi-value field
189189
foreach($value as $val) {
190190
$val = $this->xmlEncode($val);

tests/XfdfFileTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function testXfdfFileCreation()
2525
'multivalue1' => array('val1', 'val2'),
2626
'nested.dummy' => 'valX',
2727
'nested.multivalue2' => array('val3', 'val4'),
28+
'nullValue' => null,
2829
);
2930

3031
$oXfdfFile = new XfdfFile($data, null, null, __DIR__);

tests/files/XfdfFileTest.xfdf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,8 @@
5959
<value>val4</value>
6060
</field>
6161
</field>
62+
<field name="nullValue">
63+
<value></value>
64+
</field>
6265
</fields>
6366
</xfdf>

0 commit comments

Comments
 (0)