2011/2/3 MoYo <m...@indepnet.net>

>  Le 03/02/2011 12:20, Denis Linvinus a écrit :
>
>
>
> 2011/2/3 MoYo <m...@indepnet.net>
>
>>  Hi,
>>
>> thanks for your interest in GLPI.
>> A similar bug report could be found here :
>> http://www.glpi-project.org/forum/viewtopic.php?id=22834
>>
>>
>> The proposed solution : replace \w by \p{L}
>> Could you test it and validate the proposed solution ?
>>
>
> No, without changes this patch don't work for me,
>
>   ok
>
>  I get
> [03-02-2011 13:36]  Новый ответ по заявке Автор Денис
> ##IFfollowup.isprivate=Да## Личный ##ENDIFfollowup.isprivate## :
> фывфыв
>
> Others IF conditions works fine.
>
> But in my version template also decoded
> @@ -208,7 +208,7 @@
>              Plugin::loadLang(strtolower($plug['plugin']));
>           }
>
> -         if ($template_datas = $this->getByLanguage($language)) {
> +         if ($template_datas =
> html_entity_decode_deep($this->getByLanguage($language))) {
>              //Template processing
>              // Decode html chars to have clean text
>              $data = html_entity_decode_deep($data);
>
>
> But html decode here do not introduce problem when template included html
> characters ?
>

can you give me some example?

i test this symbols, in template:
&#1081;
&#1094;
&#1082;

they converting to Russian letters, without any problems.

there is raw html result, it displaying correctly
<body><p><br /><br /><strong>[03-02-2011 15:50]  Новый ответ по заявке Автор
Денис   :</strong><br />фывфы1243234</p>
<p>&#1081;<BR><br />&#1094;<BR><br />&#1082;<BR><br /><br /><br />


>
>
>  but even with that, patch from forum don't work for Russian letters in
> template.
> But this one (remove Ui from regexp)
>
>
> Removing Ui modifier will introduce troubles.
> U is used to ungreedy the regular expression (find the shortest instead of
> the longuest, problems if you have the same condition twice).
> Maybe ungreedy using ? works better (your initial proposition).
> i modifier permit to be not case sensitive... removing it may also cause
> troubles.
>

Sorry, Ui also works, but with

-                  && $data['##'.$if_field.'##'] == $out[2][$key]) {
+                  && $data['##'.$if_field.'##'] ==
htmlentities(utf8_decode($out[2][$key]))) {

don't. (when i test first time i remove Ui before"htmlentities(utf8_decode("
)

so, there is working patch

--- ./notificationtemplate.class.php    2011-01-18 17:04:00.000000000 +0300
+++ ./notificationtemplate.class.php.new    2011-02-03 15:53:15.000000000
+0300
@@ -208,7 +208,7 @@
             Plugin::loadLang(strtolower($plug['plugin']));
          }

-         if ($template_datas = $this->getByLanguage($language)) {
+     if ($template_datas =
html_entity_decode_deep($this->getByLanguage($language))) {
             //Template processing
             // Decode html chars to have clean text
             $data = html_entity_decode_deep($data);
@@ -324,13 +324,13 @@

    static function processIf($string, $data) {

-      if (preg_match_all("/##IF([a-z\.]*)[=]?([\w ]*)##/i",$string,$out)) {
+      if (preg_match_all("/##IF([a-z\.]*)[=]?([\p{L}\w
]*)##/i",$string,$out)) {
          foreach ($out[1] as $key => $tag_infos) {
             $if_field = $tag_infos;
             //Get the field tag value (if one)
-            $regex_if = "/##IF".$if_field."[=]?[\w
]*##(.*)##ENDIF".$if_field."##/Uis";
+            $regex_if = "/##IF".$if_field."[=]?[\p{L}\w
]*##(.*)##ENDIF".$if_field."##/Uis";
             //Get the else tag value (if one)
-            $regex_else = "/##ELSE".$if_field."[=]?[\w
]*##(.*)##ENDELSE".$if_field."##/Uis";
+            $regex_else = "/##ELSE".$if_field."[=]?[\p{L}\w
]*##(.*)##ENDELSE".$if_field."##/Uis";
             if (empty($out[2][$key])){ // No = : check if ot empty or not
null
                if (isset($data['##'.$if_field.'##'])
                   && $data['##'.$if_field.'##'] != ''




>
>
>
>
>       if (preg_match_all("/##IF([a-z\.]*)[=]?([\p{L}\w
> ]*)##/",$string,$out)) {
>          foreach ($out[1] as $key => $tag_infos) {
>             $if_field = $tag_infos;
>             //Get the field tag value (if one)
>             $regex_if = "/##IF".$if_field."[=]?[\p{L}\w
> ]*##(.*)##ENDIF".$if_field."##/s";
>             //Get the else tag value (if one)
>             $regex_else = "/##ELSE".$if_field."[=]?[\p{L}\w
> ]*##(.*)##ENDELSE".$if_field."##/s";
>
> with
> -         if ($template_datas = $this->getByLanguage($language)) {
> +         if ($template_datas =
> html_entity_decode_deep($this->getByLanguage($language))) {
>
> also works, as my.
> I don't understand for what this change,
>
> -                  && $data['##'.$if_field.'##'] == $out[2][$key]) {
>
> +                  && $data['##'.$if_field.'##'] == 
> htmlentities(utf8_decode($out[2][$key]))) {
>
> without it my template works fine.
>
>
> I do not understand it also.
>
> If you can get us a complete patch if will be perfect.
>
> Regards
>
>
> _______________________________________________
> Glpi-dev mailing list
> Glpi-dev@gna.org
> https://mail.gna.org/listinfo/glpi-dev
>
>
_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev

Reply via email to