From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- includes/tidy/Html5Depurate.php | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 includes/tidy/Html5Depurate.php (limited to 'includes/tidy/Html5Depurate.php') diff --git a/includes/tidy/Html5Depurate.php b/includes/tidy/Html5Depurate.php new file mode 100644 index 00000000..23e445fa --- /dev/null +++ b/includes/tidy/Html5Depurate.php @@ -0,0 +1,45 @@ + 'http://localhost:4339/document', + 'timeout' => 10, + 'connectTimeout' => 0.5, + ) ); + } + + public function tidy( $text ) { + $wrappedtext = '' . + '' . $text . ''; + + $req = MWHttpRequest::factory( $this->config['url'], + array( + 'method' => 'POST', + 'timeout' => $this->config['timeout'], + 'connectTimeout' => $this->config['connectTimeout'], + 'postData' => array( + 'text' => $wrappedtext + ) + ) ); + $status = $req->execute(); + if ( !$status->isOK() ) { + throw new Exception( "Error contacting depurate service: " . $status->getWikiText() ); + } elseif ( $req->getStatus() !== 200 ) { + throw new Exception( "Depurate returned error: " . $status->getWikiText() ); + } + $result = $req->getContent(); + $startBody = strpos( $result, "" ); + $endBody = strrpos( $result, "" ); + if ( $startBody !== false && $endBody !== false && $endBody > $startBody ) { + $startBody += strlen( "" ); + return substr( $result, $startBody, $endBody - $startBody ); + } else { + return $text . "\n"; + } + } +} -- cgit v1.2.3-54-g00ecf