EllisLab text mark
Advanced Search
     
Flashdata disappears when certain ASCII codes appear in message
Posted: 26 October 2012 05:13 PM   [ Ignore ]
Avatar
Joined: 2012-10-25
5 posts

Hi, folks. I’ve been chasing a flashdata problem for a few hours, and finally found a simple test to illustrate the problem (CI 2.1). I’m running Apache 2.2.21 on XP.

This works just fine:

$strTest =' "Hello World" ';
$this->session->set_flashdata('error'$strTest); 

However, this fails, showing no flashdata:

$strTest =' “Hello World” ';
$this->session->set_flashdata('error'$strTest); 

Note that in the second example, the only difference is the use of the left and right double quotes (ASCII “ and ”), instead of the more common double quote (ASCII ").

Unfortunately, htmlspecialchars() doesn’t escape these double quote characters.

Am I missing something? Is there a character set restriction that I’m not aware of?

Thanks for any help.

 
Posted: 26 October 2012 06:33 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-25
5 posts

After a little more digging, this appears to be a cookies problem.

The following code

setcookie('myQuoteTest',     ' "Hello World" ');
setcookie('myQuoteTestFail'' “Hello World” ');
print_r($_COOKIE); 

produces the following:

Array
(
    
[myQuoteTest] =>  "Hello World" 
    
[myQuoteTestFail] =>  Hello World 
    
...

The double quotes get stripped from the failing cookie. The CI session cookie gets confused because the flashdata component of the session variable is two characters shorter than expected.

Here’s the CI session cookie for the failing flashdata:

[lnp_ci_session] => a:7:{
            s
:10:"session_id";
            
s:32:"9bf1eacee64a35e8f3f3eaa3abf210c9";
            
s:10:"ip_address";
            
s:9:"127.0.0.1";
            
s:10:"user_agent";
            
s:99:"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4";
            
s:13:"last_activity";
            
i:1351286819;
            
s:9:"user_data";
            
s:0:"";
            
s:15:"flash:old:error";
            
s:15:" "Hello World" "
            
s:15:"flash:new:error";
            
s:15:" Hello World ";   // note that the embedded double quotes are missing 
                                    // and the string is only 13 characters long
            
}56f72386e3e36b0ce9805c245db1895c 

Note sure where to take this next, since it seems to be a php situation. Any thoughts?