Mailing List Archive

Including an external html (or php) file
Is there a way to display an external html or php file within a page? Or even
just insert some raw html code? the <nowiki> tag doesn't seem to work for
this.

Bruce
Re: Including an external html (or php) file [ In reply to ]
Bruce Bertrand wrote:
> Is there a way to display an external html or php file within a page?

No. You could add a way, I suppose, but there isn't one.

> Or even
> just insert some raw html code? the <nowiki> tag doesn't seem to work for
> this.

Arbitrary HTML is dangerous: cross-site scripting attacks; hijacking
sessions of other users, etc.

-- brion vibber (brion @ pobox.com)
Re: Including an external html (or php) file [ In reply to ]
On Tuesday 01 June 2004 04:10 pm, Brion Vibber wrote:
> Bruce Bertrand wrote:
> > Is there a way to display an external html or php file within a page?
>
> No. You could add a way, I suppose, but there isn't one.
>
> > Or even
> > just insert some raw html code? the <nowiki> tag doesn't seem to work
> > for this.
>
> Arbitrary HTML is dangerous: cross-site scripting attacks; hijacking
> sessions of other users, etc.
>
> -- brion vibber (brion @ pobox.com)

Perhaps an <html> tag that would disable the wiki processing and could itself
be disabled in the config file (similar to the whitelist flag, only give it
to SysAdmins).

My goal it to insert an html form into a particular page (and protect that
page). I've modified some html through the WikiMedia:All_messages pages (in
particular, to display a Creative Commons Liscence notice, but I don't fully
understand the way that these messages are parsed, and I don't think I'd be
able to do what I'm trying to do with it.

Maybe I just need to create a static html page and have my wiki pages link to
it, but I'd rather stay in the wiki.

Bruce
RE: Including an external html (or php) file [ In reply to ]
Brion Vibber wrote:
>Bruce Bertrand wrote:
>> Is there a way to display an external html or php file within a page?
>No. You could add a way, I suppose, but there isn't one.
>> Or even
>> just insert some raw html code? the <nowiki> tag doesn't seem to work for
>> this.
>Arbitrary HTML is dangerous: cross-site scripting attacks; hijacking
>sessions of other users, etc.

Another related question: is there a way to *link* to an external file on a file system, using perhaps UNC (Universal Naming Convention), e.g. [<\\servername\sharename\path\filename> External File] or some such syntax? On some Mediawiki installations other than Wikipedia (e.g. ours) this would be extremely useful to link to non-wiki flat files (e.g. Microsoft Word).

Michael Richards
Re: Including an external html (or php) file [ In reply to ]
On Tue, Jun 01, 2004 at 04:42:02PM -0400, Bruce Bertrand wrote:
> On Tuesday 01 June 2004 04:10 pm, Brion Vibber wrote:
> > Bruce Bertrand wrote:
> > > Is there a way to display an external html or php file within a page?
> >
> > No. You could add a way, I suppose, but there isn't one.
> >
> > > Or even
> > > just insert some raw html code? the <nowiki> tag doesn't seem to work
> > > for this.
> >
> > Arbitrary HTML is dangerous: cross-site scripting attacks; hijacking
> > sessions of other users, etc.
> >
> > -- brion vibber (brion @ pobox.com)
>
> Perhaps an <html> tag that would disable the wiki processing and could itself
> be disabled in the config file (similar to the whitelist flag, only give it
> to SysAdmins).
>
> My goal it to insert an html form into a particular page (and protect that
> page). I've modified some html through the WikiMedia:All_messages pages (in
> particular, to display a Creative Commons Liscence notice, but I don't fully
> understand the way that these messages are parsed, and I don't think I'd be
> able to do what I'm trying to do with it.
>
> Maybe I just need to create a static html page and have my wiki pages link to
> it, but I'd rather stay in the wiki.

I had to do something similar in order to get Google AdSense to work for me. With much thanks to Tim Starling:

In LocalSettings.php I added $wgAdSenseText with the desired code block.

I use a slightly older instance of MediaWiki so the file names have changed on this next part:

In OutputPage.php in function doWikiPass2 I added $wgAdSenseText to the list of globals and then right before the end of the
function I added:

$text = str_replace("{{ADSENSE}}", $wgAdSenseText, $text);

That line successfully replaces {{ADSENSE}} on any wiki page with the desired code block.

Hope this helps!
Re: Including an external html (or php) file [ In reply to ]
Richards,Michael wrote:
> Another related question: is there a way to *link* to an external
> file on a file system, using perhaps UNC (Universal Naming
> Convention), e.g. [<\\servername\sharename\path\filename> External
> File] or some such syntax? On some Mediawiki installations other than
> Wikipedia (e.g. ours) this would be extremely useful to link to
> non-wiki flat files (e.g. Microsoft Word).

If you enable the file: URL scheme you can do this:
file://servername/sharename/path/filename
or
[file://servername/sharename/path/filename External file]

There's no option for it so you have to make the change manually. In
includes/Parser.php there's a function like this:
/* private */ function replaceExternalLinks( $text )
{
$fname = "Parser::replaceExternalLinks";
wfProfileIn( $fname );
$text = $this->subReplaceExternalLinks( $text, "http", true );
$text = $this->subReplaceExternalLinks( $text, "https", true );
$text = $this->subReplaceExternalLinks( $text, "ftp", false );
$text = $this->subReplaceExternalLinks( $text, "irc", false );
$text = $this->subReplaceExternalLinks( $text, "gopher", false ;
$text = $this->subReplaceExternalLinks( $text, "news", alse );
$text = $this->subReplaceExternalLinks( $text, "mailto", false );
wfProfileOut( $fname );
return $text;
}

Add in another line to the bunch:
$text = $this->subReplaceExternalLinks( $text, "file", false );

(The boolean value controls whether to allow using those external URLs
as image links if they edit with '.jpg' or '.gif' etc.) Such file URLs
might not work on different platforms, but if you're an all-windows shop
it should work consistently.

-- brion vibber (brion @ pobox.com)