* Move PHP 5-friendly XHTML doctype hack to Sanitizer, use for sig checks.
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 14 Jan 2006 17:42:08 +0000 (17:42 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 14 Jan 2006 17:42:08 +0000 (17:42 +0000)
  Fixes use of named entities in sigs on PHP 5

RELEASE-NOTES
includes/GlobalFunctions.php
includes/Sanitizer.php
maintenance/parserTests.inc

index 195b171..7382e61 100644 (file)
@@ -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 ===
index cc1285f..26b013a 100644 (file)
@@ -1685,8 +1685,7 @@ function wfIsWellFormedXml( $text ) {
  */
 function wfIsWellFormedXmlFragment( $text ) {
        $html =
-               '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' .
-               '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' .
+               Sanitizer::hackDocType() .
                '<html>' .
                $text .
                '</html>';
index 20e2a27..45f7a49 100644 (file)
@@ -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 = "<!DOCTYPE html [\n";
+               foreach( $wgHtmlEntities as $entity => $codepoint ) {
+                       $out .= "<!ENTITY $entity \"&#$codepoint;\">";
+               }
+               $out .= "]>\n";
+               return $out;
+       }
+
 }
 
 ?>
index fef88e0..868b020 100644 (file)
@@ -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 = "<!DOCTYPE html [\n";
-               foreach( $wgHtmlEntities as $entity => $codepoint ) {
-                       $out .= "<!ENTITY $entity \"&#$codepoint;\">";
-               }
-               $out .= "]>\n";
-               return $out;
-       }
-
        function wellFormed( $text ) {
                $html =
-                       $this->hackDocType() .
+                       Sanitizer::hackDocType() .
                        '<html>' .
                        $text .
                        '</html>';