[pmwiki-devel] Safely adding a %confirm% custom WikiStyle

Eemeli Aro eemeli at gmail.com
Fri Jul 18 02:39:37 CDT 2008


I want to add a custom WikiStyle %confirm% in the style of %newwin%,
which would add a javascript onclick event handler to a link
confirming that the user wants to follow it. Currently, I've
implemented it as the following hack but I was wondering if there's a
better way of doing this?

$WikiStyle['confirm']['rel'] = '\' onclick=\'return confirm("Are you sure?")';

The $WikiStyleAttr array already has 'rel' linked to A elements by
default, which means that using %rel=something confirm% will result in
<a rel='' onclick='return confirm("Are you sure?")'  href='...'>,
overwriting the 'something'. This isn't a problem for me as I'm not
using the rel attribute. A slightly nicer way might be to use the more
arcane 'rev' instead and also set $WikiStyleAttr['rev'] = 'a'; .

I can't use the 'onclick' attribute directly, as that would require me
to set $WikiStyleAttr['onclick'] = 'a'; as well, which would lead to
the possibility of writing inline javascript in pages, which I don't
want to allow. Or am I missing something?

eemeli



More information about the pmwiki-devel mailing list