php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78307 Strange caracter in $_POST with mbstring.encoding_translation = On
Submitted: 2019-07-17 15:16 UTC Modified: 2019-07-18 00:46 UTC
From: heidy dot hery at gmail dot com Assigned:
Status: Not a bug Package: mbstring related
PHP Version: 7.3.7 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
17 - 2 = ?
Subscribe to this entry?

 
 [2019-07-17 15:16 UTC] heidy dot hery at gmail dot com
Description:
------------
Description : 

When I use multipart/form-data for posting data to the php side. 
The $_POST variable output strange caracter like "réveiller". in place of "réveiller".

But I've tested two sites. with the same Apache/PHP configuration... and on the first site, multipart/form-data work correctly, but not on the second site... it's a very strange and non stable behaviour.

the php.ini configuration was as follow :

mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.encoding_translation = On

I've made a test with enctype="application/x-www-form-urlencoded" and the data showed correctly in the $_POST array.

So in order to have the correct behaviour with enctype="multipart/form-data", I've to set the following value in php.ini

mbstring.internal_encoding = UTF-8
mbstring.http_input = UTF-8
mbstring.encoding_translation = Off


Now all is working correctly.

my php version is 7.3.5
apache 2.4.39
Windows 10 x64.





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-17 16:17 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: *Unicode Issues +Package: mbstring related
 [2019-07-17 16:17 UTC] requinix@php.net
What's the value of your default_charset setting? Are your pages being served in UTF-8 encoding or something else?
 [2019-07-17 18:55 UTC] heidy dot hery at gmail dot com
-Status: Feedback +Status: Open
 [2019-07-17 18:55 UTC] heidy dot hery at gmail dot com
Hello,

my default parameters in php.ini is :

-------------------------------------------------------
; PHP's built-in default media type is set to text/html.
; http://php.net/default-mimetype
default_mimetype = "text/html"

; PHP's default character set is set to UTF-8.
; http://php.net/default-charset
default_charset = "UTF-8"

; PHP internal character encoding is set to empty.
; If empty, default_charset is used.
; http://php.net/internal-encoding
;internal_encoding =

; PHP input character encoding is set to empty.
; If empty, default_charset is used.
; http://php.net/input-encoding
;input_encoding =

; PHP output character encoding is set to empty.
; If empty, default_charset is used.
; See also output_buffer.
; http://php.net/output-encoding
;output_encoding =

-----------------------------------------------

I use in all my html/php file the header :

<meta charset="utf-8"/>
or
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

in my httpd.conf

I add the line :

AddDefaultCharset utf-8

But that's doesn't change anything, I've put also accept-charset="utf-8" in the form attribute.

The only thing that's worked it's when I've put the "http_input" to UTF-8 and turn off the "encoding_translation".
 [2019-07-18 00:44 UTC] yohgaki@php.net
-Status: Open +Status: Not a bug
 [2019-07-18 00:44 UTC] yohgaki@php.net
In general, you shouldn't use automatic encoding translation because current HTML specification explicitly states client(browser) must send specified char encoding.

In addition, automatic encoding detection requires long and unique enough char data for correct detection. Your input should be short and/or not unique.

Set mbstring.http_input = UTF-8 or none.
 [2019-07-18 00:46 UTC] yohgaki@php.net
Don't forget to set default_charset=UTF-8. This is the setting where you should set char encoding. <meta> may be used, but it's not recommended.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Sep 15 18:01:27 2019 UTC