EllisLab text mark
Advanced Search
     
POST Encoding Problem
Posted: 13 September 2012 04:29 AM   [ Ignore ]
Avatar
Joined: 2009-03-11
74 posts

I’ve been trying to fix this for three days now and any help is appreciated.

When I Publish / Edit an entry (using default control panel theme) I’m facing character encoding issues.

File Encoding
I’ve checked all the view files, controllers, modules, helpers etc. All these files have UTF8 set as file encoding not ANSI.

Database Encoding
I’ve checked the database, table, and column encodings and collations. All are set tu utf8 and utf8_general_ci

Database Connection Encoding
I have modified mysql driver so that it manually sets character encoding using SET NAMES directive.

HTML Encoding
I have fixed HTML encoding and it has this line:
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8”/>

I even added charset accept-charset=“utf-8” to the form_open in EE Form Helper class.

Nothing solved my problem.

Then I have checked the content of $_POST variable by adding

print_R($_POST); exit; 

on line 134 of /system/expressionengine/controllers/cp/content_publish.php

Now if I enter ççç into title field I get this output:

Array
(
    .
    .
    .
    
[title] => Ã§Ã§Ã§
    
.
    .
    .

So basically there is an issue with character encoding and $_POST variable.

I have checked charset directives in php.ini and set them all to UTF8.

I have added default charset into Apache configuration file..


I am out of ideas.

Any help is really much appreciated.

Thanks,

Can Berkol

** edit:

When I enter data using non EE HTML Forms or phpmyadmin data is saved into DB correctly with no encoding issues.

 Signature 

biber Ltd.
http://biberltd.com

 
Posted: 14 September 2012 05:01 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-31
4773 posts

Hi Can,

I see the same thing when I follow these steps, but when I remove the print_R() function and just submit the entry, it looks like everything goes through. The entry’s title is “ççç”, as you’d expect. That’s what’s stored in the DB as well. You’ve done some great troubleshooting, but could you take a step back and share with me the ultimate problem you’re having that started this whole thing?

 Signature 

Need some help? | Current Versions: EE 2.6.1 // MM 1.2.1

 
Posted: 15 September 2012 05:39 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-11
74 posts

Hi Kevin,

With me the data is not stored correctly. However; now I figured out that this is something to do with the enctype attribute of the form tag.

If I remove this enctype=“multipart/form-data” from the form tag, then everything goes smoothly.

This is the weirdest issu I’ve faced in my professional web development life smile

All theresearch so far points me to Apache Tomcat servers. Apparently, this is common issue in that server environment but I am not running or have installed Tomcat. We have dedicated servers and we do not run Java.

So I continue my research..

We’ll see.

I still suspect that this may be caused by false file encoding. Don’t know yet.

 Signature 

biber Ltd.
http://biberltd.com

 
Posted: 15 September 2012 07:05 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-11
74 posts

now I have added this in line 253 of system/expressionengine/libraries/api/Api_channel_entries.php

echo mb_detect_encoding($data['title']);Exit; 


The result is UTF-8 but echo $data[‘title’] still outputs ç.

I think God is bored and playing with me.

 Signature 

biber Ltd.
http://biberltd.com

 
Posted: 15 September 2012 07:38 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-11
74 posts

I solved the issue but based on W3 specifications this shouldn’t work - or maybe I am reading some outdated document.. Anyways..

I changed the lines 93 & 98 in

/system/codeigniter/system/helpers/form_helper.php

respectively to

$attributes .= ' enctype="multipart/form-data;charset=utf-8"'

and

$attributes['enctype''multipart/form-data;charset=utf-8'

Notice this part: ;charset=utf-8

Well, I don’t know if you want to include this in your next update but having it probably won’t harm anyone :o)

 Signature 

biber Ltd.
http://biberltd.com

 
Posted: 17 September 2012 04:24 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-31
4773 posts

This is the weirdest issu I’ve faced in my professional web development life smile

Whew, character sets will do it every time!

Well, I don’t know if you want to include this in your next update but having it probably won’t harm anyone :o)

I don’t have to make this change for everything to work smoothly on my server, so I suspect the issue lies elsewhere. That said, if including it just helps avoid issues like the ones you’re having without introducing issues for others, that could be a good thing. I’ll make sure to pass the word along. Thanks!

Anything else I can help you with?

 Signature 

Need some help? | Current Versions: EE 2.6.1 // MM 1.2.1

 
Posted: 22 September 2012 04:07 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-11
74 posts

Umm.. smile That fix breaks the file uploading capability. That forces me to go back deep into Apache settings..

 Signature 

biber Ltd.
http://biberltd.com

 
Posted: 24 September 2012 04:21 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-31
4773 posts

Hmm.. ok, let’s reset the changes you’ve made in EE and CI’s codebase. Be on the lookout for an email from me. I’d like to get a first-hand look at this to see what’s up.

 Signature 

Need some help? | Current Versions: EE 2.6.1 // MM 1.2.1

 
Posted: 25 September 2012 12:35 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-31
4773 posts

Hi Can,

Just checking in to make sure you got my email. Do you need me to re-send it?

 Signature 

Need some help? | Current Versions: EE 2.6.1 // MM 1.2.1

 
Posted: 27 September 2012 05:11 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-11
74 posts

Sorry for the delay. I’ve just send the details. Thanks.

 Signature 

biber Ltd.
http://biberltd.com

 
Posted: 27 September 2012 04:48 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-31
4773 posts

No problem! Just posting a note here to let onlookers know that we’re working privately on this for the time being. I’ll post an update back here once we have something to share!

 Signature 

Need some help? | Current Versions: EE 2.6.1 // MM 1.2.1

 
Posted: 05 November 2012 03:28 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-31
4773 posts

Looks like this one was resolved after recompiling apache with PHP on their server. If anyone else is having similar issues and that doesn’t resolve it for them, please open up a new support request and we’ll be glad to help you out!

 Signature 

Need some help? | Current Versions: EE 2.6.1 // MM 1.2.1