1 Aug 2008 01:51
Re: [MediaWiki-CVS] SVN: [38275] trunk/extensions/CSS/CSS.php
On Thu, Jul 31, 2008 at 6:25 PM, Brion Vibber <brion@...> wrote: > Icky... but perhaps no good way around it I guess. :) > > The tricky bit is that for HTML mode you want to wrap the "<![CDATA[" > and "]]>" bits in comments (/* blah */) so they don't interfere with the > JS or CSS code. > > Does that necessarily generally work? Bah, this shouldn't be so > annoyingly hard... Yeah, I see the problem. There are two reasonable solutions I see. One: public static function escapeCdata( $data ) { if( strpos( ']]>', $data ) == false ) { return $data; } return ''; } Two: public static function escapeCssForCdata( $css ) { return str_replace( ']]>', ']]\\00003E', $css ); } The first one is potentially annoying, but in both CSS and JavaScript it should be easy to work around the limitation. The second one is maybe nicer for CSS, *except* that I'm not totally sure that it would always work.(Continue reading)
RSS Feed