Index: trunk/phase3/includes/HTMLForm.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class HTMLForm { |
5 | | - |
6 | 5 | static $jsAdded = false; |
7 | 6 | |
8 | 7 | /* The descriptor is an array of arrays. |
Index: trunk/phase3/includes/Html.php |
— | — | @@ -256,11 +256,13 @@ |
257 | 257 | * @return string Raw HTML |
258 | 258 | */ |
259 | 259 | public static function inlineScript( $contents ) { |
260 | | - global $wgHtml5, $wgJsMimeType; |
| 260 | + global $wgHtml5, $wgJsMimeType, $wgWellFormedXml; |
261 | 261 | |
262 | 262 | $attrs = array(); |
263 | 263 | if ( !$wgHtml5 ) { |
264 | 264 | $attrs['type'] = $wgJsMimeType; |
| 265 | + } |
| 266 | + if ( $wgWellFormedXml && preg_match( '/[<&]/', $contents ) ) { |
265 | 267 | $contents = "/*<![CDATA[*/$contents/*]]>*/"; |
266 | 268 | } |
267 | 269 | return self::rawElement( 'script', $attrs, $contents ); |
— | — | @@ -294,15 +296,15 @@ |
295 | 297 | * @return string Raw HTML |
296 | 298 | */ |
297 | 299 | public static function inlineStyle( $contents, $media = null ) { |
298 | | - global $wgHtml5; |
| 300 | + global $wgHtml5, $wgWellFormedXml; |
299 | 301 | |
300 | 302 | $attrs = array(); |
301 | 303 | if ( !$wgHtml5 ) { |
302 | | - # Technically we should probably add CDATA stuff here like with |
303 | | - # scripts, but in practice, stylesheets tend not to have |
304 | | - # problematic characters anyway. |
305 | 304 | $attrs['type'] = 'text/css'; |
306 | 305 | } |
| 306 | + if ( $wgWellFormedXml && preg_match( '/[<&]/', $contents ) ) { |
| 307 | + $contents = "/*<![CDATA[*/$contents/*]]>*/"; |
| 308 | + } |
307 | 309 | if ( $media !== null ) { |
308 | 310 | $attrs['media'] = $media; |
309 | 311 | } |