summaryrefslogtreecommitdiff
path: root/includes/parser/Tidy.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
committerPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
commit9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch)
tree46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/parser/Tidy.php
parent78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff)
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/parser/Tidy.php')
-rw-r--r--includes/parser/Tidy.php28
1 files changed, 13 insertions, 15 deletions
diff --git a/includes/parser/Tidy.php b/includes/parser/Tidy.php
index 95f83621..38f22fd8 100644
--- a/includes/parser/Tidy.php
+++ b/includes/parser/Tidy.php
@@ -1,4 +1,9 @@
<?php
+/**
+ * HTML validation and correction
+ *
+ * @file
+ */
/**
* Class to interact with HTML tidy
@@ -16,8 +21,8 @@ class MWTidy {
* If tidy isn't able to correct the markup, the original will be
* returned in all its glory with a warning comment appended.
*
- * @param string $text Hideous HTML input
- * @return string Corrected HTML output
+ * @param $text String: hideous HTML input
+ * @return String: corrected HTML output
*/
public static function tidy( $text ) {
global $wgTidyInternal;
@@ -26,9 +31,6 @@ class MWTidy {
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'.
'<head><title>test</title></head><body>'.$text.'</body></html>';
- # Tidy is known to clobber tabs; convert them to entities
- $wrappedtext = str_replace( "\t", '&#9;', $wrappedtext );
-
if( $wgTidyInternal ) {
$correctedtext = self::execInternalTidy( $wrappedtext );
} else {
@@ -39,9 +41,6 @@ class MWTidy {
return $text . "\n<!-- Tidy found serious XHTML errors -->\n";
}
- # Convert the tabs back from entities
- $correctedtext = str_replace( '&#9;', "\t", $correctedtext );
-
return $correctedtext;
}
@@ -71,7 +70,7 @@ class MWTidy {
* @param $text String: HTML to check
* @param $stderr Boolean: Whether to read from STDERR rather than STDOUT
* @param &$retval Exit code (-1 on internal error)
- * @retrun mixed String or null
+ * @return mixed String or null
*/
private static function execExternalTidy( $text, $stderr = false, &$retval = null ) {
global $wgTidyConf, $wgTidyBin, $wgTidyOpts;
@@ -119,15 +118,13 @@ class MWTidy {
$retval = -1;
}
- wfProfileOut( __METHOD__ );
-
if( !$stderr && $cleansource == '' && $text != '' ) {
// Some kind of error happened, so we couldn't get the corrected text.
// Just give up; we'll use the source text and append a warning.
- return null;
- } else {
- return $cleansource;
+ $cleansource = null;
}
+ wfProfileOut( __METHOD__ );
+ return $cleansource;
}
/**
@@ -137,7 +134,7 @@ class MWTidy {
* 'pear install tidy' should be able to compile the extension module.
*/
private static function execInternalTidy( $text, $stderr = false, &$retval = null ) {
- global $wgTidyConf, $IP, $wgDebugTidy;
+ global $wgTidyConf, $wgDebugTidy;
wfProfileIn( __METHOD__ );
$tidy = new tidy;
@@ -145,6 +142,7 @@ class MWTidy {
if( $stderr ) {
$retval = $tidy->getStatus();
+ wfProfileOut( __METHOD__ );
return $tidy->errorBuffer;
} else {
$tidy->cleanRepair();