From cba74e148380fc3aa23e5ab547f69e52c5d7bc4f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 14 Jan 2006 17:42:08 +0000 Subject: [PATCH] * Move PHP 5-friendly XHTML doctype hack to Sanitizer, use for sig checks. Fixes use of named entities in sigs on PHP 5 --- RELEASE-NOTES | 2 ++ includes/GlobalFunctions.php | 3 +-- includes/Sanitizer.php | 20 ++++++++++++++++++++ maintenance/parserTests.inc | 19 +------------------ 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 195b17174c..7382e61a14 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -487,6 +487,8 @@ fully support the editing toolbar, but was found to be too confusing. * Allow input of the stub from a compressed file instead of stdin for dumpTextPass.php; easier to get errors back on the shell * Added an attractive space on the namespace selector on contribs +* Move PHP 5-friendly XHTML doctype hack to Sanitizer, use for sig checks. + Fixes use of named entities in sigs on PHP 5 === Caveats === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index cc1285f8e5..26b013a624 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1685,8 +1685,7 @@ function wfIsWellFormedXml( $text ) { */ function wfIsWellFormedXmlFragment( $text ) { $html = - '' . + Sanitizer::hackDocType() . '' . $text . ''; diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index 20e2a270a0..45f7a49d5d 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -1055,6 +1055,26 @@ class Sanitizer { return $text; } + /** + * Hack up a private DOCTYPE with HTML's standard entity declarations. + * PHP 4 seemed to know these if you gave it an HTML doctype, but + * PHP 5.1 doesn't. + * + * Use for passing XHTML fragments to PHP's XML parsing functions + * + * @return string + * @static + */ + function hackDocType() { + global $wgHtmlEntities; + $out = " $codepoint ) { + $out .= ""; + } + $out .= "]>\n"; + return $out; + } + } ?> diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index fef88e0732..868b020b14 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -668,26 +668,9 @@ class ParserTest { return $text; } - /** - * Hack up a private DOCTYPE with HTML's standard entity declarations. - * PHP 4 seemed to know these if you gave it an HTML doctype, but - * PHP 5.1 doesn't. - * @return string - * @access private - */ - function hackDocType() { - global $wgHtmlEntities; - $out = " $codepoint ) { - $out .= ""; - } - $out .= "]>\n"; - return $out; - } - function wellFormed( $text ) { $html = - $this->hackDocType() . + Sanitizer::hackDocType() . '' . $text . ''; -- 2.20.1