0

I am using CURL-PHP to post data to server. Options are set to curl through curl_setopt function. But somehow anonymous user enters "&" in his password. As data is collected in xml so as Xml's drawback it stops there and fires some XML Exception. If i used CDATA then it may not parse that password and ultimately authentication wil be failed. I used php encoding functions like htmlentities,html_entit_decode,utf8_encode,utf8_encode,urlencode nad urldecode. But the issue is same. Is there any method to send "&" through XML and posted that data thurh CURL. As per my knowledge, CURL itself internally parses.

Thanks,

Pranav
  • 143
  • 1
  • 3
  • 15

1 Answers1

0

First of all ensure that XML string contains &amp in password before posting

(<password>123&amp;</password> or <user password="123&amp;"></user> for 123&amp;

htmlentities() must be applied to $password, nor to $xml_data. Than ensure that it attached to curl request like curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);

Without any additional encodings. It should work! In other cases problem on POST handler side.

GDP
  • 8,109
  • 6
  • 45
  • 82
VolCh
  • 349
  • 3
  • 9
  • You should update your answer to sth more readable using some ` to hightligh your code. – j0k Jul 06 '12 at 14:40