CSO PassThru tag and extension

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
Disclaimer: This software is offered free and "as is". Use at your own risk. We assume no liability for its use or misuse.

Warning: For security reasons, allowing unrestricted HTML on a publicly editable wiki is strongly discouraged. Users can get up to all sorts of mischief with Javascript, for example. So, read and understand Documentation:Security before proceeding.

The CSO_PassThru extension allows you to put any HTML inside a <CSO_PassThru> tag and have it shunted unchanged to the output page.

CSO_PassThru tag usage example:

<PassThru><a href="http://en.csharp-online.net/" target="C#">
C# Online.NET</a></PassThru>

To register the extension, add this line to <mediawikihome>/LocalSettings.php:

include ("extensions/CSO_PassThru.php");

And, place the CSO_PassThru extension in the <mediawikihome>/extensions directory.

<?php
# CSO_PassThru - extension to pass HTMl thru to article
# CSharp-Online.NET (C) 2006 Chang & Wagers Associates
# Usage: <CSO_PassThru> article text </CSO_PassThru>
# The text between the tags is passed to the article output
# without change.
# Note: The output is not interpreted as WikiText but directly
# included in the HTML output. So, Wiki markup is not supported.
# Warning: For security reasons, allowing unrestricted HTML on a
# publicly editable wiki is strongly discouraged.
#
# To activate the extension, add this line to LocalSettings.php:
# include("extensions/CSO_PassThru.php");
 
//Add the hook function call to an array defined earlier in wiki code execution.
$wgExtensionFunctions[] = "wfCSO_PassThru";
 
// Register the tag and associated callback function with the Wiki parser.
function wfCSO_PassThru()
   {  # register the extension with the WikiText parser
   global $wgParser;
   $wgParser->setHook ( "CSO_PassThru", "CSO_PassThru" );
   }
 
# Callback function to render text from between tags to article
function CSO_PassThru ($text)
   {
   return $text;
   }
?>

Note: It is a good idea to butt the closing </CSO_PassThru> tage up against the end of your inserted HTML. Otherwise, MediaWiki may insert a <p> tag there.

$wgRawHtml

As of Mediawiki version 1.5, you can allow raw, unchecked HTML between <html> tags by setting:

$wgRawHTML = true;

This, too, is very dangerous on a publicly editable site; so, it cannot be enabled unless you've restricted editing to trusted users only with $wgWhitelistEdit.

Refer to Help:$wgRawHtml for the latest information.


Personal tools