ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

POST Encoding Problem

September 13, 2012 4:29am

Subscribe [1]
  • #1 / Sep 13, 2012 4:29am

    biberltd

    54 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.

  • #2 / Sep 14, 2012 5:01pm

    Kevin Smith

    4784 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?

  • #3 / Sep 15, 2012 5:39am

    biberltd

    54 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 😊

    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.

  • #4 / Sep 15, 2012 7:05am

    biberltd

    54 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.

  • #5 / Sep 15, 2012 7:38am

    biberltd

    54 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)

  • #6 / Sep 17, 2012 4:24pm

    Kevin Smith

    4784 posts

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

    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?

  • #7 / Sep 22, 2012 4:07pm

    biberltd

    54 posts

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

  • #8 / Sep 24, 2012 4:21pm

    Kevin Smith

    4784 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.

  • #9 / Sep 25, 2012 12:35pm

    Kevin Smith

    4784 posts

    Hi Can,

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

  • #10 / Sep 27, 2012 5:11am

    biberltd

    54 posts

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

  • #11 / Sep 27, 2012 4:48pm

    Kevin Smith

    4784 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!

  • #12 / Nov 05, 2012 2:28pm

    Kevin Smith

    4784 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!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases