|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-06-14 19:16 UTC] pollita@php.net
[2004-06-14 20:57 UTC] john at pearcey dot net
[2004-06-15 09:09 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 19:00:02 2025 UTC |
Description: ------------ I am using the Java class HttpURLConnection to post variables to a php script and I'm encoding them using URLEncoder (UTF-8). The POST variables do not seem to be decoded correctly when a double or single quote is in the stream. A backslash character is prepended to it making it impossible for me to send for example: select * from MyTable where MyColumn="brill" I end up with select * from MyTable where MyColumn=\"brill\" I have checked the string going to the server and it lookes like this for the example above: select+*+from+MyTable+where+MyColumn%3D%22brill%22 which of course is correct for UTF-8. I have not tested this on Linux. Reproduce code: --------------- HttpURLConnection l_connection = (HttpURLConnection)m_url.openConnection(); l_connection.setDoOutput( true ); String l_postVars = URLEncoder.encode("MySQL", "UTF-8") + "=" + URLEncoder.encode("select * from MyTable where MyColumn=\"brill\"", "UTF-8"); OutputStreamWriter l_os = new OutputStreamWriter( l_connection.getOutputStream() ); l_os.write( l_postVars, 0, l_postVars.length() ); l_os.flush(); PHP code: echo $_POST['MySQL']; Expected result: ---------------- select * from MyTable where MyColumn="brill" Actual result: -------------- select * from MyTable where MyColumn=\"brill\"