Http_build_query in php

Source: Internet
Author: User
Http_build_query remote attackers can exploit this vulnerability to obtain sensitive memory information. Please use it with caution

Http_build_query remote attackers can exploit this vulnerability to obtain sensitive memory information. Please use it with caution

When we use CURL to post data, we need to set post data.
Curl_setopt ($ c, CURLOPT_POSTFIELDS, $ post_data );

Assume that $ data is
The Code is as follows:
$ Data = array (
'Name' => 'scofield ',
'Time' => '2014-2-3'
)

Next, you need to convert $ data into a string.
$ Post_data = http_build_query ($ data );
When http_build_query is used for conversion
Curl_setopt ($ c, CURLOPT_POSTFIELDS, $ post_data );

It seems that there is no problem. However, in actual operations, $ post_data is not post. Therefore, after writing a conversion method, It will be OK.
The Code is as follows:
Function getStr ($ array, $ Separator = '&'){
If (empty ($ array ))
Return;
If (! Is_array ($ array )){
Return $ array;
}
$ ReturnStr = '';
Foreach ($ array as $ key => $ val ){
$ Temp = '';
If (is_array ($ val )){
For ($ I = 0; $ I <count ($ val); $ I ++ ){
$ ReturnStr. = $ key. '['. $ I. ']'. '='. $ val [$ I]. $ Separator;
}
} Else {
$ ReturnStr. = $ key. '='. $ val. $ Separator;
}
}
$ ReturnStr = substr (trim ($ returnStr), 0,-1 );
Return $ returnStr;
}

Thanks to the test http_build_query ($ data, "", "&") of Huang Bin-huangbin kids shoes. You don't need to write your own parsing method.

Http_build_query remote attackers can exploit this vulnerability to obtain sensitive memory information. Please use it with caution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.