Skip to content

Commit

Permalink
Merge pull request #251 from mikehaertl/249-fix-null-values
Browse files Browse the repository at this point in the history
Issue #249 Fix infinite loop with null values in form data
  • Loading branch information
mikehaertl authored Jul 30, 2021
2 parents 8a6fe16 + 31e5ec6 commit 97b80fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/XfdfFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function writeFields($fp, $fields)
if (!is_array($value)) {
$value = array($value);
}
if (isset($value[0])) {
if (array_key_exists(0, $value)) {
// Numeric keys: single or multi-value field
foreach($value as $val) {
$val = $this->xmlEncode($val);
Expand Down
1 change: 1 addition & 0 deletions tests/XfdfFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testXfdfFileCreation()
'multivalue1' => array('val1', 'val2'),
'nested.dummy' => 'valX',
'nested.multivalue2' => array('val3', 'val4'),
'nullValue' => null,
);

$oXfdfFile = new XfdfFile($data, null, null, __DIR__);
Expand Down
3 changes: 3 additions & 0 deletions tests/files/XfdfFileTest.xfdf
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@
<value>val4</value>
</field>
</field>
<field name="nullValue">
<value></value>
</field>
</fields>
</xfdf>

0 comments on commit 97b80fb

Please sign in to comment.