Subject UtfNormal::cleanUp() to the same tests as UtfNormal::toNFC()
[lhc/web/wiklou.git] / extensions / UnicodeConverter.php
index 44cc706..7ab7fe3 100644 (file)
@@ -4,11 +4,13 @@
 # Given a string in UTF-8, it converts it to HTML entities suitable for 
 # an ISO 8859-1 web page.
 
+# Not a valid entry point, skip unless MEDIAWIKI is defined
+if (defined('MEDIAWIKI')) {
 $wgExtensionFunctions[] = "wfUnicodeConverter";
 
 function wfUnicodeConverter() {
-
-require_once( "SpecialPage.php" );
+global $IP;
+require_once( "$IP/includes/SpecialPage.php" );
 
 class UnicodeConverter extends SpecialPage
 {
@@ -23,20 +25,20 @@ class UnicodeConverter extends SpecialPage
 
                $q = $wgRequest->getText( 'q' );
                $encQ = htmlspecialchars( $q );
-               $action = $wgTitle->getLocalUrl();
-               $ok = wfMsg( "ok" );
+               $action = $wgTitle->escapeLocalUrl();
+               $ok = htmlspecialchars( wfMsg( "ok" ) );
 
-               $wgOut->addHTML( "
-<form name=ucf method=post action=\"$action\">
-<textarea rows=15 cols=80 name=q>
-$encQ
-</textarea><br />
-<input type=submit name=submit value=\"$ok\"><br /><br />
-</form>" );
+               $wgOut->addHTML( <<<END
+<form name="ucf" method="post" action="$action">
+<textarea rows="15" cols="80" name="q">$encQ</textarea><br />
+<input type="submit" name="submit" value="$ok" /><br /><br />
+</form>
+END
+);
 
                if ( !is_null( $q ) ) {
-                       $html = wfUtf8ToHTML( $q );
-                       $wgOut->addHTML( "\n\n\n" . nl2br( $html ) . "\n<hr>\n" .
+                       $html = wfUtf8ToHTML( htmlspecialchars( $q ) );
+                       $wgOut->addHTML( "\n\n\n" . nl2br( $html ) . "\n<hr />\n" .
                          nl2br( htmlspecialchars( $html ) ) . "\n\n" );
                }
        }
@@ -47,4 +49,5 @@ SpecialPage::addPage( new UnicodeConverter );
 $wgMessageCache->addMessage( "unicodeconverter", "Unicode Converter" );
 
 } # End of extension function
+} # End of invocation guard
 ?>