Pluf Framework

Issue 457: Crash when displaying Mb content :

Reported by Baptiste Db, May 5, 2010

Indefero 1.0, pluf latest. Somehow linked with : 
http://projects.ceondo.com/p/indefero/issues/118/

PlufErrorHandlerException making GET request to /p/.../issues/290/
2 : htmlspecialchars() [<a 
href='function.htmlspecialchars'>function.htmlspecialchars</a&g
t;]: Invalid multibyte sequence in argument
PHP 	.../src/Pluf/Template.php, line 236
URI 	GET /p/.../issues/290/
Stacktrace ▼

    * PlufErrorHandler [No File, line 0]
      ▼ Args
      Arg 	Name 	Value
      0 	$code 	

      2

      1 	$string 	

      htmlspecialchars() [<a 
href='function.htmlspecialchars'>function.htmlspecialchars</a&g
t;]: Invalid multibyte sequence in argument

      2 	$file 	

      /home/indefero/pluf-master/src/Pluf/Template.php

      3 	$line 	

      236

      4 	? 	

      Array
      (
          [mixed] => f�v  2, 2010
          [echo] => 
      )


Some nice IRC comments from piouPiouM : 

[10:42:06] bathizte: got this error today : wanted to edit a ticket, 
and instead had a pluf trace log : 
htmlspecialchars()  Invalid multibyte sequence in argument
[10:47:08] piouPiouM: bathizte: you have a file and line of error?
[10:49:38] bathizte: piouPiouM: Template.php, line 236
[10:50:27] bathizte: seems like a mb_ handler pb
[10:51:30] piouPiouM: bathizte: yes, idf or pluf should use a substr 
(for example) 
[11:23:58] bathizte: piouPiouM, do you mean htmlspecialchars is not 
mb friendly ? 
[11:36:23] piouPiouM: bathizte: no, but in IDF/Pluf a no mb function 
was used and she has cut a multibyte char in the middle
[11:37:31] piouPiouM: and htmlspecialchars should block above. ([FR] 
si mon anglais est moisi je suis preneur de corrections )

Comment 1 by Baptiste Db, May 17, 2010

Looks like strftime() is systemwide locale dependant. 

in Pluf_Template_dateFormat: 
setting this
 
    setlocale (LC_TIME, 'FR.utf8','fra'); 

before 

    return strftime($format, strtotime($date));

did the trick for me. 

Maybe we should have a config var to use together with setlocale to 
provide a utf-8 compatible output ?

Comment 2 by Baptiste Db, Jun 15, 2010

Other idf, other config, same strftime issue.
I don't understand, because there, the locales seem set up correctly 
: 

# locale
8<--
LC_TIME="fr_FR.UTF-8"
8<--

A phpinfo confirms this point. However, I *have to set the locale 
immediately before the strftime call*. 

    setlocale(LC_TIME, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 
'fr.UTF-8');

(looks more correct than my precendent codeline)

I tried to set this in the index.php, but it did not work. 

So maybe this is a fcgi together with another php webapp related pb.

Comment 3 by Baptiste Db, Aug 2, 2010

okay, the locale was set in the Translation but they were not forced 
to utf-8...
See attached patch

Comment 4 by Thomas Keller, Mar 10, 2011

Slightly changed (removed the dublettes) and committed in revision 
0b090e2.
Status: Fixed

Created: 3 years 1 month ago by Baptiste Db

Updated: 2 years 3 months ago

Status: Fixed

Followed by: 2 persons

Labels:
Priority:Medium
Type:Defect