php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31862 Ability to turn off magic_quotes for parse_str().
Submitted: 2005-02-06 20:54 UTC Modified: 2012-09-23 16:31 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php at koterov dot ru Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 4.3.10 OS: all
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at koterov dot ru
New email:
PHP Version: OS:

 

 [2005-02-06 20:54 UTC] php at koterov dot ru
Description:
------------
parse_str() always quotes arguments when magic_quotes_gpc is active on startup (php.ini or .htaccess configured). But seems I cannot SWITCH OFF magic_quotes_gpc on runtime FOR parse_str(). (I understand that it is useless to try to switch off magic_quotes_gpc for purposes other than parse_str!).

Seems it's a restriction of ini_set(), not parse_str() itself.

Reproduce code:
---------------
<?php
# magic_quotes_gpc MUST be ON in .htaccess or php.ini!
$qs = 'a="b"';
ini_set("magic_quotes_gpc", 0);
parse_str($qs, $p);
echo "<pre>".print_r($p, 1)."</pre>";
?>

Expected result:
----------------
Array
(
    [a] => "b"
)



Actual result:
--------------
Array
(
    [a] => \"b\"
)



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-14 12:24 UTC] jdespatis at yahoo dot fr
Hi, i have the same need

In fact, I encode an array into a query string thanks to http_build_query()

and i want to get my array back, so i use parse_str, however, this function protects slash if magic quotes is ON

AND it's impossible in a script to set the magic quotes to off, so it's impossible to tell parse_str not to protect the slashes, i have to do a little loop after to strip slashes

Should be nice to add an extra param to this function to say if yes or no slashes should be protected, instead of using the configuration of magic quotes (that can't be changed at runtime)
 [2012-09-23 16:31 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 [2012-09-23 16:31 UTC] nikic@php.net
Closing as magic quotes were dropped in PHP 5.4.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jun 01 09:01:26 2025 UTC