Changeset:
        b23f255a9577
        
https://sourceforge.net/p/mrbs/hg-code/ci/b23f255a95778115b2dacc8e8fd7fa5808532440
Author:
        Campbell Morrison <[email protected]>
Date:
        Tue Oct 04 18:21:50 2016 +0100
Log message:

Formatted the error output better for the browser by replacing spaces at the 
beginning of a line with non-breaking spaces

diffstat:

 web/functions_error.inc |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 59e938d185dc -r b23f255a9577 web/functions_error.inc
--- a/web/functions_error.inc   Tue Oct 04 16:28:22 2016 +0100
+++ b/web/functions_error.inc   Tue Oct 04 18:21:50 2016 +0100
@@ -14,6 +14,21 @@
 }
 
 
+// Replace leading spaces in $string with non-breaking spaces
+function replace_leading_spaces($string)
+{
+  return preg_replace('/\G /', '&nbsp;', $string);
+}
+
+
+function to_html($string)
+{
+  $lines = explode("\n", $string);
+  $lines = array_map(__NAMESPACE__ . "\\replace_leading_spaces", $lines);
+  return implode("<br>\n", $lines);
+}
+
+
 function output_error($heading, $body, $show_data=false)
 {
   if ($show_data)
@@ -25,8 +40,8 @@
   
   if (ini_get('display_errors'))
   {
-    echo nl2br("<b>$heading</b>");
-    echo nl2br($body);
+    echo "<b>" . to_html($heading) . "</b>\n";
+    echo to_html($body);
   }
   if (ini_get('log_errors'))
   {

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to