'; if ( is_object( $title ) && $title->exists() ) { # Article actually in the db $params = "action=raw&ctype=text/css&$rawProtection"; $url = $title->getLocalURL( $params ); $headItem .= Html::linkedStyle( $url ); } elseif ( $css[0] == '/' ) { # Regular file $base = $wgCSSPath === false ? $wgStylePath : $wgCSSPath; $url = wfAppendQuery( $base . $css, $rawProtection ); # Verify the expanded URL is still using the base URL if ( strpos( wfExpandUrl( $url ), wfExpandUrl( $base ) ) === 0 ) { $headItem .= Html::linkedStyle( $url ); } else { $headItem .= ''; } } else { # sanitized user CSS $css = Sanitizer::checkCss( $css ); # Encode data URI and append link tag $dataPrefix = 'data:text/css;charset=UTF-8;base64,'; $url = $dataPrefix . base64_encode( $css ); $headItem .= Html::linkedStyle( $url ); } $headItem .= ''; $parser->getOutput()->addHeadItem( $headItem ); return ''; } /** * @param Parser $parser * @return bool true */ public static function onParserFirstCallInit( $parser ) { $parser->setFunctionHook( 'css', 'CSS::CSSRender' ); return true; } /** * @param RawPage $rawPage * @param string $text * @return bool true */ public static function onRawPageViewBeforeOutput( &$rawPage, &$text ) { global $wgCSSIdentifier; if ( $rawPage->getRequest()->getBool( $wgCSSIdentifier ) ) { $text = Sanitizer::checkCss( $text ); } return true; } }