• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space

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