IRC Logs - Change from htmlentities to htmlspecialchars
authorBen Shum <bshum@biblio.org>
Fri, 17 Aug 2012 21:31:20 +0000 (17:31 -0400)
committerBen Shum <bshum@biblio.org>
Fri, 17 Aug 2012 21:33:48 +0000 (17:33 -0400)
htmlentities() was doing a very poor job at rendering unicode characters
in our IRC log pages. Changing over to htmlspecialchars() and defining
"UTF-8" directly improves the rendering.

Signed-off-by: Ben Shum <bshum@biblio.org>
irc_logs.php

index b1e0e95..a1be6ec 100755 (executable)
@@ -159,15 +159,15 @@ JAVASCRIPT;
                         $raw_line = substr($raw_line, 2);
                     }
                     $line_user = '';
-                    $line = '<td class="ircaction" colspan="2">' . htmlentities($raw_line) . '</td>';
+                    $line = '<td class="ircaction" colspan="2">' . htmlspecialchars($raw_line, ENT_QUOTES, "UTF-8") . '</td>';
                 } elseif(preg_match('/^<([^>]*)> (.*)$/', $raw_line, $line_parts)) {
-                    $line_user = '<td class="ircuser">' . htmlentities($line_parts[1]) . '</td>';
-                    $line = '<td>' . htmlentities($line_parts[2]) . '</td>';
+                    $line_user = '<td class="ircuser">' . htmlspecialchars($line_parts[1], ENT_QUOTES, "UTF-8") . '</td>';
+                    $line = '<td>' . htmlspecialchars($line_parts[2], ENT_QUOTES, "UTF-8") . '</td>';
                 }
             } else {
                 $line_user = '';
                 $line_date = '';
-                $line = '<td colspan="3">' . htmlentities($raw_line) . '</td>';
+                $line = '<td colspan="3">' . htmlspecialchars($raw_line, ENT_QUOTES, "UTF-8") . '</td>';
             }
             echo '<tr class="irclog', $extra_class, '"><td><a href="#line', $cur_line, '" name="line', $cur_line, '">#</a></td>', $line_date, $line_user, $line, '</tr>';
         }