page: convert error messages to html strings
[minimedit.git] / page.php
index 1488f1c5904f7a637208305037bfd73bb02e7861..fb0c4ddcba96d7edd2b3cd28bbbd3f1ea75017fc 100644 (file)
--- a/page.php
+++ b/page.php
@@ -55,7 +55,7 @@ function getoutput($blocks = [])
        # keep either login or logout parts depending on user level
        global $User;
        $hideclass = empty($User) ? 'login' : 'logout';
-       $doc = preg_replace('{\s*<(p|li|span) class="'.$hideclass.'">.*?</\1>}s', '', $doc);
+       $doc = preg_replace('{\s*<([a-z]+) class="'.$hideclass.'">.*?</\1>}s', '', $doc);
 
        return preg_replace_callback(
                '{ (?<! <!--BLOCK: ) \[\[ ([^] ]+) ([^]]*) \]\] }x',
@@ -90,8 +90,8 @@ function fail($error)
        }
        include_once 'page.inc.php';
        ob_start();
-       require_once '500.inc.html';
-       print getoutput(['debug' => $error]);
+       require '500.inc.html';
+       print getoutput(['debug' => htmlspecialchars($error)]);
 }
 
 set_exception_handler('fail');
@@ -179,6 +179,15 @@ $Place = [
 ];
 
 if (isset($Article->raw)) {
+       if ($User and $User->admin("edit $Page$Args")) {
+               # restore meta tags in static contents for editing
+               foreach (array_reverse($Article->meta) as $metaprop => $val) {
+                       $Article->raw = sprintf(
+                               '<meta property="%s" content="%s" />'."\n",
+                               $metaprop, $val
+                       ) . $Article->raw;
+               }
+       }
        $Article->raw = '<div class="static">'."\n\n".$Article->raw."</div>\n\n";
 }