IncludeExternalFile.py

Description

Outputs the external file's content.

Download & Release Notes

Download

Moin Version

Release Notes

IncludeExternalFile.py

1.9.2

refactored Albert Ma's original implementation

Usage

You must know which coding is used for the content of your file and give it to the macro for correct decoding (default: utf-8 - works for utf-8 and also for pure ascii).

If your file is utf-8 with BOM and you want to get rid of the BOM, use utf-8-sig as coding.

To make this work, you must edit your wiki config and add a line like this to the config section:

    IncludeExternalFileRoot = "E:/LocalExternalDataFileFolder"

It points to point to the storage location of any files on the server that you wish to include using this macro.

Safety notes

You can include arbitrary html files using this macro, the macro just uses the html file's content "as is" (aside from decoding it).

So, if the file contains html not suitable for embedding into a wiki page at the place you use the macro, you might destroy correct layout of the page.

Your file must not contain <html> / </html> and similar tags for obvious reasons.

/!\ XSS risk /!\

As your file can contain arbitrary html, you should only make this macro available to trusted users (that means all users of your wiki need to be trusted if you install this macro).

Also, make sure that the files that can be used with the macro only contain trusted html made by trusted people / from trusted data sources.

Some evil html could use Javascript and steal your session cookie or do other bad stuff!

Examples

<<IncludeExternalFile(data.html)>>
<<IncludeExternalFile(data.html, utf-8)>>
<<IncludeExternalFile(data.html, utf-8-sig)>>
<<IncludeExternalFile(data.html, utf-16-le)>>
<<IncludeExternalFile(data/file.txt)>>

AlbertMa - Dead link removed

refactored by ThomasWaldmann

License

GNU GPL v2 or later

Discussion

...

MoinMoin: MacroMarket/IncludeExternalFile (last edited 2010-06-17 07:43:27 by ThomasWaldmann)