Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session library - storing/retrieving data containing slashes (CI 2.1.3) #1990

Closed
webspy opened this issue Nov 10, 2012 · 3 comments
Closed
Milestone

Comments

@webspy
Copy link

webspy commented Nov 10, 2012

There is a potential bug in the Session library related to storing/retrieving data containing slashes.

The issue can be reproduced using the following piece of code:

$this->load->library('session');
$data = $this->session->userdata('data');
echo var_dump($data);

$data = array('test \\ test');
$this->session->set_userdata('data', $data);
echo var_dump($data);

In CodeIgniter 2.1.3 the _serialize() method of the Session library only escapes the first level of the supplied array. When the data is unserialized on read the unserialize() function emits a warning similar to the following:

Message: unserialize(): Error at offset 42 of 45 bytes

This issue seems to be fixed in CodeIgniter 3.0 by walking the supplied array recursively.

@tubalmartin
Copy link
Contributor

I confirm the bug spotted by webspy. CI 3.0 fixes it.

@blasto333
Copy link
Contributor

I fixed this if you need the code before then:
https://github.com/EllisLab/CodeIgniter/commits?author=blasto333

@captbaritone
Copy link
Contributor

Just a note for future travelers: As @tubalmartin mentioned, this bug is fixed in 3.0. For the curious, it was fixed in ca20d84. I wrote up a short history of what's actually going on with this issue here: #2784

This issue could probably be closed, unless the goal is to get the fix merged into the current stable branch.

@narfbg narfbg closed this as completed Dec 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants