• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

HTML encoding of foreign language characters

Status
Not open for further replies.

webmasterd

Chevereto Member
I have a problem, when someone wants to share a picture from my image hosting to Facebook, accents, ñ and other Latin characters are converted into codes (Ex. Á = & aacute), what should I do?

// Attach my PrintScreen!

Observe the image, instead of showing "República" it appears and shared: "República"
 

Attachments

  • share to Facebook.png
    share to Facebook.png
    58.5 KB · Views: 3
Actually the solution is quite easy:

Open lib/G/functions.php and replace this:
PHP:
    // Safe for HTML output
    function safe_html($var) {
        if(!is_array($var)) {
            return $var === NULL ? NULL : htmlentities($var, ENT_QUOTES, 'UTF-8');
        }
        $safe_array = array();
        foreach($var as $k => $v) {
            $safe_array[$k] = is_array($v) ? safe_html($v) : ($v === NULL ? NULL : htmlentities($v, ENT_QUOTES, 'UTF-8'));
           
        }
        return $safe_array;
    }

With this:
PHP:
    // Safe for HTML output
    function safe_html($var) {
        if(!is_array($var)) {
            return $var === NULL ? NULL : htmlspecialchars($var, ENT_QUOTES, 'UTF-8'); // htmlspecialchars keeps ñ, á and all the UTF-8 valid chars
        }
        $safe_array = array();
        foreach($var as $k => $v) {
            $safe_array[$k] = is_array($v) ? safe_html($v) : ($v === NULL ? NULL : htmlspecialchars($v, ENT_QUOTES, 'UTF-8'));
           
        }
        return $safe_array;
    }
 
Status
Not open for further replies.
Back
Top