Simplewiki 1.0RC5 bug in links decorators and onclick function

11 views
Skip to first unread message

camille sauvaget

unread,
Jul 30, 2011, 8:55:21 AM7/30/11
to simpl...@googlegroups.com
Hi,

I would like to add some onclick function to anchor links but this operation fails.
When I wrote %l onclick="Effect.ScrollTo('Title'); return false;"[[Anchor:#Title]]

Effect.ScrollTo is a scriptaculous framework function.

The decorator is just being printed on screen like normal text. I cannot find any workaround to realize HTML code like :
<a href="#Title" onclick="Effect.ScrollTo('Title'); return false;">Go to Title</a>

I think the problem come from parentheses in attribute value as I add them, I automaticaly have something like :
%l onclick=&quote;Effect.ScrollTo();&quote;%<a href="#Title">Go To Title</a>

in my HTML source.

Is there any workaround to have javascripts call in links with simplewiki ?

 

Henrik Bechmann

unread,
Jul 30, 2011, 9:02:37 AM7/30/11
to simpl...@googlegroups.com
I've purposely excluded parenthesis from attributes to make the code more secure.

The workaround is to write html in the markup:

%c html%{{{html markup}}}

or 

|:pre html:|{{{
...
}}}

For security, this html can be disallowed with 

$wiki->allow_html(FALSE);

- Henrik

 

--
You received this message because you are subscribed to the Google Groups "simplewiki" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simplewiki/-/fkhwkkF10X0J.
To post to this group, send email to simpl...@googlegroups.com.
To unsubscribe from this group, send email to simplewiki+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simplewiki?hl=en.



--
bechmann.ca

Henrik Bechmann

unread,
Jul 30, 2011, 9:14:44 AM7/30/11
to simpl...@googlegroups.com
... you can also experiment with

$wiki->parser()->argchars($argchars); // (default is '^()')

Camille Sauvaget

unread,
Jul 30, 2011, 9:36:37 AM7/30/11
to simpl...@googlegroups.com
Thanks a lot for your reply, 

I tried your second proposition unfortunately, this did not do the tricks. I setted argchars to '.' so that the internal regex should match anything. 

I think the solution to write down links in my page is the only one.

Again thanks for your reply.


2011/7/30 Henrik Bechmann <hen...@bechmann.ca>

Henrik Bechmann

unread,
Jul 30, 2011, 9:39:52 AM7/30/11
to simpl...@googlegroups.com
The dot is interpreted as a literal character in character sets.

Try:

'^\r\n'

(ie allow anything but carriage return/newline)

- H

Camille Sauvaget

unread,
Jul 30, 2011, 9:54:52 AM7/30/11
to simpl...@googlegroups.com
No more chance with that...

For reference here is my complete markup 
%l onclick="Effect.ScrollTo('EXPERIENCES'); return false;"%[[Anchor:#EXPERIENCES|Expériences professionnelles]]

real exemple from http://www.camillesauvaget.net/page/cv. links are on the left in the sidebar.

2011/7/30 Henrik Bechmann <hen...@bechmann.ca>

Henrik Bechmann

unread,
Jul 30, 2011, 12:05:54 PM7/30/11
to simpl...@googlegroups.com
That's because the regex is compiled in the constructor before archars(...) gets a chance to change the argument character set. Duh.

I've changes argchars as follows

public function argchars($argchars = NULL)
{
if (!is_null($argchars))
{
$this->_argchars = $argchars;
// recompile regex
$this->_set_rules();
$this->_set_re($this->_rules);
}
return $this->_argchars;
}

so that it now recompiles the regex when the arg chars are changed.

I've rolled this change into 1.05.zip and uploaded the result. Download 1.05, update muster_simpliwiki_parser.php, and try again.

Thanks for bringing this to my attention!

- Henrik

Henrik Bechmann

unread,
Jul 30, 2011, 12:12:07 PM7/30/11
to simpl...@googlegroups.com
Just to be clear, here's my argchar statement:

$wiki->parser()->argchars('^\r\n');

I've tested this with 

%l onclick="alert('hello');return false;"%[[#test|test click]]

and it works.

- H

Camille Sauvaget

unread,
Jul 30, 2011, 5:06:23 PM7/30/11
to simpl...@googlegroups.com
Great ! 

It works for me too.

Thanks for fixing this.

Camille

2011/7/30 Henrik Bechmann <hen...@bechmann.ca>

Henrik Bechmann

unread,
Jul 30, 2011, 5:16:42 PM7/30/11
to simpl...@googlegroups.com
Excellent!

I've started a "Tips and Tricks" section on the website with this item here: http://simplewiki.org/topics

- Henrik

Henrik Bechmann

unread,
Aug 17, 2012, 2:00:48 AM8/17/12
to simpl...@googlegroups.com, hen...@bechmann.ca
... or if you want to allow \n\r (as I do) you can use

$wiki->parser()->argchars('^\e'); // all chars except ascii escape - not likely to be encountered

I know I know, It's kind of a stupid workaround. One of these days I'll take argchars out of the characterset brackets ([]), to allow '(.|\n|\r)'. In this case the default would be '[^()]' instead of '^()' as it is now.

- H
Reply all
Reply to author
Forward
0 new messages