[wikka-community] Include JavaScript into Wikka pages

mahefa randimbisoa dotmg
Tue Feb 19 09:12:16 GMT 2008


Obviously, for security reasons, you should not allow javascript to be
included in wikka pages. If your wiki is set up properly so that no
malicious user won't be able to edit any page (intranet, closed wiki,
...), you can set the value of the double_doublequote_html config to
raw. No tag will be stripped when you insert html code, then, you can
just code

""<script>alert(document.cookie);</script>""

If you would like that only admin should be able to insert javascript code
I would propose this hack:

1) Create an action that can embed JS into page , like {{javascript
src="showcookie"}}

//BEGIN: content of actions/javascript.php
<?php
// hardcode here pages that are treated as javascript code
if (in_array($src, array('showcookie', '...')))
{
 echo '<script src="'.$this->href('raw', $src).'"></script>'
}
?>
//END: content of actions/javascript.php

Then, you edit pages showcookie, ... and insert there the js code. Not
forgetting setting acls to admin only.

Hope this helps.

PS: For the syntax error below, I guess you get it from Javascript
Error Console while trying to reference a js page? If you'd like to
get only the raw code of a wiki page without headers and footers (the
html tags), append /raw to its url.

2008/2/19, Raffael <rjr84 at student.canterbury.ac.nz>:
> hello everyone,
>
> I would like to include some javascript into one/some wikka pages. do
> you know a good way to do that?
>
> <script> tags are being filtered.
>
> what should i do if i get such an error:
>
> Error: syntax error
> Source: http://www.bla.com/w/test.js
> Row: 1
> Source:
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> I guess it is the wrong doctype. The test file I have uses: <!DOCTYPE
> html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
>
> Cheers,
>  Raffa
>
>
>
> _______________________________________________
> WikkaWiki Community mailing list
> community at wikkawiki.org
> http://mail.wikkawiki.org/mailman/listinfo/community_wikkawiki.org
>
>
>


-- 
Work hard at whatever you do! (Ecc. 9. 10a, CEV)
Mahefa aka DotMG
http://dotmg.net/




More information about the community mailing list