Enfore ISO-8859-1 encoding for htmlentities().
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 17 Nov 2013 22:39:39 +0000 (23:39 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 17 Nov 2013 22:39:39 +0000 (23:39 +0100)
The default was changed to UTF-8 in PHP 5.4, but diogenes relies on latin1.

include/Barrel/Menu.php
include/Barrel/Page.php
include/Text/Wiki/Render/Xhtml/Code.php
include/diogenes.session.inc.php
include/diogenes/diogenes.core.page.inc.php
include/diogenes/diogenes.misc.inc.php

index 7703288..73400e1 100644 (file)
@@ -141,7 +141,7 @@ class Diogenes_Barrel_Menu
     {
       $mentry = $mcache[$mid];
 //      echo "pid : $pid, location : $location<br/>";
-      $entry = htmlentities(stripslashes($mentry['title']), ENT_QUOTES);
+      $entry = htmlentities(stripslashes($mentry['title']), ENT_QUOTES, "ISO-8859-1");
       if ($mentry['pid'])
       {
         $link = call_user_func($pid_to_url, $mentry['pid']);
index 15d4d89..75ffe9c 100644 (file)
@@ -171,7 +171,7 @@ class Diogenes_Barrel_Page
     $props = $this->props;
     
     $topbar = array ();
-    $from = htmlentities($caller->script_uri());
+    $from = htmlentities($caller->script_uri(), ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
     
     if ($props['PID']) {    
       $hp = $this->barrel->getPID('');
index 306c3e4..f95267c 100644 (file)
@@ -84,7 +84,7 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render {
             // convert entities.
             $text = str_replace("\t", "    ", $text);
             $text = "<html>\n$text\n</html>";
-            $text = htmlentities($text);
+            $text = htmlentities($text, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
             $text = "<pre$css><code$css_html>$text</code></pre>";
             
         } else {
@@ -92,11 +92,11 @@ class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render {
             // convert tabs to four spaces,
             // convert entities.
             $text = str_replace("\t", "    ", $text);
-            $text = htmlentities($text);
+            $text = htmlentities($text, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
             $text = "<pre$css><code$css_code>$text</code></pre>";
         }
         
         return "\n$text\n\n";
     }
 }
-?>
\ No newline at end of file
+?>
index 7fa5286..f6c1559 100644 (file)
@@ -142,7 +142,7 @@ class DiogenesSession extends DiogenesCoreSession {
 
     if (isset($_COOKIE['DiogenesLogin']))
       $page->assign('username', $_COOKIE['DiogenesLogin']);
-    $page->assign('post',htmlentities($page->script_uri()));
+    $page->assign('post',htmlentities($page->script_uri(), ENT_COMPAT | ENT_HTML401, "ISO-8859-1"));
     $page->assign('challenge',$this->challenge);
     $page->assign('md5',$page->url("md5.js"));
     $page->display('login.tpl');
index 4de8399..9113ba1 100644 (file)
@@ -186,7 +186,7 @@ function diogenes_func_diff($params)
     if ($line) {
       if (!isset($old) || ($old != $class))
         $out .= "<div class=\"$class\">";
-      $out .= htmlentities($line);
+      $out .= htmlentities($line, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
     }
     $old = $class;
   }
@@ -227,7 +227,7 @@ function diogenes_func_extval($params) {
   foreach($diogenes_db_cache[$cache_id] as $id=>$val)
     $html_out .= "  <option value=\"$id\"".
                     ($selected==$id ? " selected=\"selected\"":"")
-                    .">".htmlentities($val)."</option>\n";
+                    .">".htmlentities($val, ENT_COMPAT | ENT_HTML401, "ISO-8859-1")."</option>\n";
   $html_out .= "</select>\n";
 
   return $html_out;
index 2a1dde9..e421026 100644 (file)
@@ -62,9 +62,9 @@ function html_accent($string)  {
   $lca = preg_split('//', $lc_accent, -1, PREG_SPLIT_NO_EMPTY);
   $uca = preg_split('//', $uc_accent, -1, PREG_SPLIT_NO_EMPTY);
   foreach($lca as $key=>$val)
-    $lch[$key] = htmlentities($val);
+    $lch[$key] = htmlentities($val, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
   foreach($uca as $key=>$val)
-    $uch[$key] = htmlentities($val);
+    $uch[$key] = htmlentities($val, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
   $newstring = str_replace($lca,$lch,$string);
   $newstring = str_replace($uca,$uch,$newstring);
   return $newstring;