diff --git a/lib/weblib.php b/lib/weblib.php index fbc605a6f04..592cf8db7fd 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2205,9 +2205,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $output = ob_get_contents(); ob_end_clean(); - if (debugging(NULL, DEBUG_DEVELOPER)) { // In developer debugging mode, convert page to XHTML strict - $output = debug_header($output); - } + $output = force_strict_header($output); if (!empty($CFG->messaging)) { $output .= message_popup_window(); @@ -2227,12 +2225,12 @@ function print_header ($title='', $heading='', $navigation='', $focus='', * See: http://tracker.moodle.org/browse/MDL-7883 * TODO: */ -function debug_header($output) { +function force_strict_header($output) { global $CFG; $strict = ''; $xsl = '/lib/xhtml.xsl'; - if (!headers_sent()) { + if (!headers_sent() && debugging(NULL, DEBUG_DEVELOPER)) { // In developer debugging, the browser will barf $ctype = 'Content-Type: '; $prolog= "\n"; @@ -2265,6 +2263,12 @@ function debug_header($output) { $output .= "__ TEST: XML well-formed error < __\n"; } } + + if (debugging()) { // In any other debugging mode > NONE, strict is on + // Substitute document-type, s (PCRE_DOTALL) + $output = preg_replace('/()/s', $strict, $output); + } + return $output; }