MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/125929
Change subject: HtmlFormatter fixes
......................................................................
HtmlFormatter fixes
* Don't fixup HTML if it hasn't been ruined by libxml2
* More detailed profiling
Change-Id: Ieabce23819f7563fdf17e3f1dfd621d853dae589
---
M includes/HtmlFormatter.php
1 file changed, 15 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/29/125929/1
diff --git a/includes/HtmlFormatter.php b/includes/HtmlFormatter.php
index a72fd59..7f590e5 100644
--- a/includes/HtmlFormatter.php
+++ b/includes/HtmlFormatter.php
@@ -254,6 +254,7 @@
wfProfileIn( __METHOD__ );
if ( $this->doc ) {
+ wfProfileIn( __METHOD__ . '-dom' );
if ( $element !== null && !( $element instanceof
DOMElement ) ) {
$element = $this->doc->getElementById( $element
);
}
@@ -269,25 +270,30 @@
$body->appendChild( $element );
}
$html = $this->doc->saveHTML();
+ wfProfileOut( __METHOD__ . '-dom' );
+
+ wfProfileIn( __METHOD__ . '-fixes' );
$html = $this->fixLibXml( $html );
+ if ( wfIsWindows() ) {
+ // Cleanup for CRLF misprocessing of unknown
origin on Windows.
+ //
+ // If this error continues in the future,
please track it down in the
+ // XML code paths if possible and fix there.
+ $html = str_replace( ' ', '', $html );
+ }
+ $html = preg_replace(
'/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
+ wfProfileOut( __METHOD__ . '-fixes' );
} else {
$html = $this->html;
}
- if ( wfIsWindows() ) {
- // Appears to be cleanup for CRLF misprocessing of
unknown origin
- // when running server on Windows platform.
- //
- // If this error continues in the future, please track
it down in the
- // XML code paths if possible and fix there.
- $html = str_replace( ' ', '', $html );
- }
- $html = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s',
'', $html );
$html = $this->onHtmlReady( $html );
+ wfProfileIn( __METHOD__ . '-flatten' );
if ( $this->elementsToFlatten ) {
$elements = implode( '|', $this->elementsToFlatten );
$html = preg_replace( "#</?($elements)\\b[^>]*>#is",
'', $html );
}
+ wfProfileOut( __METHOD__ . '-flatten' );
wfProfileOut( __METHOD__ );
return $html;
--
To view, visit https://gerrit.wikimedia.org/r/125929
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieabce23819f7563fdf17e3f1dfd621d853dae589
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits