WordPress.org

Ready to get started?Download WordPress

Forums

dbview
[resolved] Charset encoding (encodeHtmlEntities) is broken by using UTF-8 (6 posts)

  1. AleksCee
    Member
    Posted 2 years ago #

    I have installed a fresh new test-WordPress and if I query a SQL like this:

    select * from wp_posts

    I only get the first "Wellcome"-Post from the german WP-Instaltion. The Umlauts are all broken and the Post is end with the first "-" in the Post.
    I have try to find out where the code goes broken... And I found this:

    if ($this->encodeHtmlEntities)
    {
    $dval = htmlentities($dval);
    }

    in "DBViewTable.class.php" at line 153.

    If I set the Calls-Attribut: public $encodeHtmlEntities = false
    all seams to by fine.

    So I take a look at the PHP-Doc and found this:
    "If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0"

    So I set the Calls Attribut back to true and change this:

    $dval = htmlentities($dval, ENT_COMPAT, get_option('blog_charset'));

    Now it's work fine.... can you take this into account.

    http://wordpress.org/extend/plugins/dbview/

  2. john ackers
    Member
    Plugin Author

    Posted 2 years ago #

    Aleks, thanks for reporting the issue and solving it! I will look at this tomorrow and correct plugin.

  3. john ackers
    Member
    Plugin Author

    Posted 2 years ago #

    Aleks

    Having looked into this more closely, in particular, this very helpful article, it looks like I shouldn't be doing any encoding/decoding for individual HTML elements. Only the special HTML characters like <, & and > etc need to be handled.

    So I am about to commit a new version that removes htmentities() and instead uses esc_textarea(), a WP function used by many plugins. It works for umlauts and the string 'Iñtërnâtiônàlizætiøn'. But the test is meaningless as I am using the default WP charset UTF-8. Can you tell me what character encoding you are using, so I can be sure that this fix works for you as well as me.

    By the way, esc_textarea() calls htmlspecialchars() which according to the article above, should also be passed the blog_charset, in the same way as you suggest above. But if you don't have problems with WP core or any other plugins, you shouldn't have any problems with the updated dbview.

    John

  4. john ackers
    Member
    Plugin Author

    Posted 2 years ago #

    Actually re-reading the title of your article makes it clear u r using UTF-8 !

  5. AleksCee
    Member
    Posted 2 years ago #

    Hi,

    I've updated the plugin and it now works correctly for me.

    Thanks!

    Alex

  6. john ackers
    Member
    Plugin Author

    Posted 2 years ago #

    Phew. Thanks Alex for the update.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags