Greetings:
So, I've got a real problem in that PHP doesn't seem to be able to
unserialize() an array that has an element containing a newline. Of
course, I've used htmlentities() to protect the serialized data.
Here's a simple example that demonstrates the problem:
-----
<?php
$blah = array("I like\nnewlines" );
echo '<html>';
echo '<body>';
if (isset($_POST['blah'])) {
if (unserialize(ht ml_entity_decod e($_POST['blah'])) === FALSE)
echo '<p>Unserializ e failed.</p>';
else
echo '<p>Unserializ e worked.</p>';
}
echo '<form method="POST" enctype="multip art/form-data"
action="test.ph p">';
echo '<input type="hidden"';
echo ' name="blah"';
echo ' value="';
echo htmlentities(se rialize($blah)) ;
echo '"';
echo '/>';
echo '<input type="submit" name="doink" value="Submit" />';
echo '</form>';
echo '</body>';
echo '</html>';
?>
So, I've got a real problem in that PHP doesn't seem to be able to
unserialize() an array that has an element containing a newline. Of
course, I've used htmlentities() to protect the serialized data.
Here's a simple example that demonstrates the problem:
-----
<?php
$blah = array("I like\nnewlines" );
echo '<html>';
echo '<body>';
if (isset($_POST['blah'])) {
if (unserialize(ht ml_entity_decod e($_POST['blah'])) === FALSE)
echo '<p>Unserializ e failed.</p>';
else
echo '<p>Unserializ e worked.</p>';
}
echo '<form method="POST" enctype="multip art/form-data"
action="test.ph p">';
echo '<input type="hidden"';
echo ' name="blah"';
echo ' value="';
echo htmlentities(se rialize($blah)) ;
echo '"';
echo '/>';
echo '<input type="submit" name="doink" value="Submit" />';
echo '</form>';
echo '</body>';
echo '</html>';
?>
Comment