Menu

#1219 dhtmltextarea editor accent not displayed

XOOPS_2.5.x
closed
core (1)
5
2013-09-14
2012-07-07
Cesag
No

With "DHTML Form with xCode" when I write a letter with accent and I click on "Preview", the text is not displayed.

Discussion

  • Michael Beck

    Michael Beck - 2013-02-20

    The problem is related to the fact that if the input string contains an invalid code unit sequence within the given encoding an empty string will be returned.

    See: http://php.net/manual/en/function.htmlspecialchars.php

    The problem is that XOOPS check everything as UTF-8, and therefore will see the ISO-8859-1 codes as "invalid codes" and will return empty string.

    Therefore check if the encoding is European ISO-8859-1, and if yes, don't use UTF-8.

    To fix it, in /class/module.textsanitizer replace the line 518:

    $text = $this->htmlSpecialChars($text);

    with

    if (mb_detect_encoding($text , 'ISO-8859-1', true)){
    $text = $this->htmlSpecialChars($text,ENT_QUOTES ,'ISO-8859-1');
    }
    else {
    $text = $this->htmlSpecialChars($text);
    }

     
  • Michael Beck

    Michael Beck - 2013-02-20
    • labels: Core - Core --> core
    • status: open --> pending
    • assigned_to: Michael Beck
     
  • Alain91

    Alain91 - 2013-02-21

    Could you describe more precisely the case ? As everything is UTF8, how could it be possible to have iso-8859-1 strings ?

     
  • Cesag

    Cesag - 2013-02-26

    Which one is better or more correct? (1-mamba solution or 2-alain01 solution proposed in mail) :

    in /class/module.textsanitizer replace the line 518:

    $text = $this->htmlSpecialChars($text);

    with

    1-mamba solution:

    if (mb_detect_encoding($text , 'ISO-8859-1', true)){
    $text = $this->htmlSpecialChars($text,ENT_QUOTES ,'ISO-8859-1');
    }
    else {
    $text = $this->htmlSpecialChars($text);
    }

    or

    2-alain01 solution:

    if ($html != 1) {
    // html not allowed
    $text = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text,'UTF-8, ISO-8859-1', true));
    $text = $this->htmlSpecialChars($text,ENT_COMPAT,'UTF-8');
    }

     

    Last edit: Cesag 2013-02-26
  • Cesag

    Cesag - 2013-02-27

    According to montuy337513 (black_beard on xoops.org), mamba's solution consumes fewer resources.

     
  • Michael Beck

    Michael Beck - 2013-09-14
    • status: pending --> closed
     

Log in to post a comment.

Monday.com Logo