Move the circular reference check to *after* redirect resolution, to avoid infinite...
[lhc/web/wiklou.git] / includes / OutputHandler.php
index 3d123c3..1f4798b 100644 (file)
@@ -123,48 +123,10 @@ function wfDoContentLength( $length ) {
  * Replace the output with an error if the HTML is not valid
  */
 function wfHtmlValidationHandler( $s ) {
-       global $IP, $wgTidyInternal, $wgTidyConf;
-       if ( $wgTidyInternal ) {
-               $tidy = new tidy;
-       
-               $tidy->parseString( $s, $wgTidyConf, 'utf8' );
-               if ( $tidy->getStatus() == 0 ) {
-                       return $s;
-               }
-
-               $errors = $tidy->errorBuffer;
-       } else {
-               // Copied from Parser::externalTidy();
-               global $wgTidyBin, $wgTidyOpts;
-
-               $cleansource = '';
-               $opts = ' -utf8';
 
-               $descriptorspec = array(
-                       0 => array( 'pipe', 'r' ),
-                       1 => array( 'file', wfGetNull(), 'a' ),
-                       2 => array( 'pipe', 'w' )
-               );
-               $pipes = array();
-               if( function_exists( 'proc_open' ) ) {
-                       $process = proc_open("$wgTidyBin -config $wgTidyConf $wgTidyOpts$opts", $descriptorspec, $pipes );
-                       if ( is_resource( $process ) ) {
-                               fwrite( $pipes[0], $s );
-                               fclose( $pipes[0] );
-                               while( !feof( $pipes[2] ) ) {
-                                       $errors .= fgets( $pipes[2], 1024 );
-                               }
-                               fclose( $pipes[2] );
-                               $ret = proc_close( $process );
-                               if( ( $ret < 0 && $errors == '' ) || $ret == 0 )
-                                       return $s;
-                       } else {
-                               return $s;
-                       }
-                       
-               } else {
-                       return $s;
-               }
+       $errors = '';
+       if ( MWTidy::checkErrors( $s, $errors ) ) {
+               return $s;
        }
 
        header( 'Cache-Control: no-cache' );
@@ -197,7 +159,7 @@ EOT;
 
        $out .= '</ul>';
        $out .= '<pre>' . htmlspecialchars( $errors ) . '</pre>';
-       $out .= '<ol>';
+       $out .= "<ol>\n";
        $line = strtok( $s, "\n" );
        $i = 1;
        while ( $line !== false ) {
@@ -206,7 +168,7 @@ EOT;
                } else {
                        $out .= '<li>';
                }
-               $out .= htmlspecialchars( $line ) . '</li>';
+               $out .= htmlspecialchars( $line ) . "</li>\n";
                $line = strtok( "\n" );
                $i++;
        }