php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34027 new line unix "\n" in hidden html are not recorded
Submitted: 2005-08-07 17:05 UTC Modified: 2005-08-07 17:20 UTC
From: test2 at nicolap dot lautre dot net Assigned:
Status: Not a bug Package: Safe Mode/open_basedir
PHP Version: 5.0.4 OS: linux
Private report: No CVE-ID: None
 [2005-08-07 17:05 UTC] test2 at nicolap dot lautre dot net
Description:
------------
Hello,    
 
run the following script and enter in the text area the    
value : 
line 1 
line 2 
 
<?php 
$out .= '<form action="test3.php" method="post">'; 
$out .= '<textarea name="body" rows="10" cols="70">'; 
if (isset($_POST['body'])) { 
        $out .= $_POST['body']; 
        $out .= '</textarea><br /><br />'."\n"; 
} else { 
        $out .= '</textarea><br /><br />'."\n"; 
} 
if (isset($_POST['body2']) && !empty($_POST['body2'])) { 
        if (strcmp($body, $body2)) { 
                $out .= "strings are the same !"; 
        } else { 
                $out .= "strings are not the same !<br/>". 
                $_POST['body']."<br/>". 
                $_POST['body2']."<br/>"; 
        } 
} else { 
        $out .= '<input type="hidden" name="body2"'.'     
value="'.$_POST['body'].'">'."\n"; 
} 
$out .= '<input type="submit" name="submit" value     
="record">';     
$out .= "</form>";     
echo $out;     
?>     
 
 
It always shows the same thing : "strings are not the    
same !" . The character new line "\n" is not recorded when    
it is coming from a hidden tag in html form. 
 
I am using safe_mode and php 5.0.4. 
 
Nicolas 

Reproduce code:
---------------
<?php
$out .= '<form action="test3.php" method="post">';  
$out .= '<textarea name="body" rows="10" cols="70">';  
if (isset($_POST['body'])) {  
        $out .= $_POST['body'];  
        $out .= '</textarea><br /><br />'."\n";  
} else {  
        $out .= '</textarea><br /><br />'."\n";  
}  
if (isset($_POST['body2']) && !empty($_POST['body2'])) {  
        if (strcmp($body, $body2)) {  
                $out .= "strings are the same !";  
        } else {  
                $out .= "strings are not the same !<br/>".  
                $_POST['body']."<br/>".  
                $_POST['body2']."<br/>";  
        }  
} else {  
        $out .= '<input type="hidden" name="body2"'.'  
value="'.$_POST['body'].'">'."\n";  
}  
$out .= '<input type="submit" name="submit" value  
="record">';  
$out .= "</form>";  
echo $out;  
?>  


Expected result:
----------------
If you enter the 2 following lines in the text area :  
line1 
line2  
  
The result of the script always shows :  
  
strings are not the same !  
line1 line2 
line1 line2 
 
Out that should show this : 
strings are the same ! 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-07 17:20 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 04:01:30 2024 UTC