[Mediawiki-l] custom extension including <script> tags

Alistair Johnson JohnsonA at rembrandt.co.nz
Tue Dec 7 00:26:19 UTC 2004


Hi Jamie,

I have done exactly that, but to no avail - the code I have that is called
by a custom tag <CalendarPopUp> is:
function renderCalendarPopUp( $input )
{
    $output = "<pre>" . "<script language=\"JavaScript\"
type=\"text/JavaScript\">\n<!--\nfunction popupEvent(ev, w, h) {\n  var winl
= (screen.width - w) / 2;\n  var wint = (screen.height - h) / 2;\n  win =
window.open(\"/escal/popups/escalEV.php?ev=\" + ev +
\"&readFile=1&readSQL=0\",\"ESCalendar\",\"scrollbars=yes,status=no,location
=no,toolbar=no,menubar=no,directories=no,resizable=yes,width=\" + w +
\",height=\" + h + \",top=\" + wint + \",left=\" + winl + \"\");\n  if
(parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n
}\n//-->\n</script>" . "</pre>";
    return $output;
}

If I remove the <pre> </pre> tags from this code then when it is passed back
to mediawiki it gets mangled as outlined below.  Am I taking an incorrect
approach?

Regards,

al.
-----Original Message-----
From: Jamie Bliss [mailto:astronouth7303 at gmail.com]

MediaWiki, for obvious security reasons, will treat scripts as random
text (meaning it will mangle it). What you have to do is make a tag
(say <popup>) that is translated by a simple extension into the needed
code. so
 <popup> 
is replaced by
 <script language="JavaScript" type="text/JavaScript">
 <!--
 function popupEvent(ev, w, h) {
  [code here]
  }
 //-->
 </script>

This is too protect wikis from more serious attacks than they already are.

<johnsona at rembrandt.co.nz> wrote:
> 
> We're using MediaWiki for a corporate Intranet and have developed a number
> of extensions which display dynamic data.  I'm currently having a couple
of
> problems integrating a php calendar (www.easilysimplecalendar.com/):
> 
> 1. I have to include the following code in the page:
> <script language="JavaScript" type="text/JavaScript">
> <!--
> function popupEvent(ev, w, h) {
>  [code here]
>  }
> //-->
> </script>
> 
> However MediaWiki is converting this to:
> <script language="JavaScript" type="text/JavaScript">
> <p><!--
> function popupEvent(ev, w, h) {
> </p>
> <pre>  [code here]
>  }
> </pre>
> <p>//-->
> </script>
> </p>
> 
> If I manually wrap the code in the <pre> tags I can get it processed by
> MediaWiki in a non-mangled state, but then I end up with an ugly box on
the
> screen:
> ----
> |
> ----
> 
> Any idea how I can work around this problem?  I'm probably missing
something
> obvious ...



More information about the MediaWiki-l mailing list