From: Aryeh Gregor Date: Sun, 23 Aug 2009 21:06:54 +0000 (+0000) Subject: Emit CDATA more intelligently X-Git-Tag: 1.31.0-rc.0~40086 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=5e72d3501e5abf7c47104268845f09f74003a711;p=lhc%2Fweb%2Fwiklou.git Emit CDATA more intelligently This fixes some possible XML invalidity from r54767: CDATA stuff was being added only if $wgHtml5 was false, instead of whenever $wgWellFormedXml is true. Also, it uses CDATA for script as well as style, but in both cases only uses it if there's a & or < somewhere. --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 59429c9077..35fb020ffe 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1,7 +1,6 @@ */"; } return self::rawElement( 'script', $attrs, $contents ); @@ -294,15 +296,15 @@ class Html { * @return string Raw HTML */ public static function inlineStyle( $contents, $media = null ) { - global $wgHtml5; + global $wgHtml5, $wgWellFormedXml; $attrs = array(); if ( !$wgHtml5 ) { - # Technically we should probably add CDATA stuff here like with - # scripts, but in practice, stylesheets tend not to have - # problematic characters anyway. $attrs['type'] = 'text/css'; } + if ( $wgWellFormedXml && preg_match( '/[<&]/', $contents ) ) { + $contents = "/**/"; + } if ( $media !== null ) { $attrs['media'] = $media; }