1. The problems:
(A) I installed DokuWiki to localhost/wiki path.
I want to make links to localhost/texts/... etc. pages.
So I can make references from wiki pages to the full sources etc.
But such links work only with the full path, like: "
http://localhost/texts"
Just "/texts" or "/../texts" etc. don't work.
It is not convenient. I will move dokuwiki to another server.
So I would need to change all such links on all pages:
substituting
http://localhost
with
http://www.mysite.net.
Thus I want the possibility to make links from the root of my server.
Like "/texts", "/forum" etc.
(In DokuWiki I use SEF with .htaccess and slashes).
(B) Links like [[#discussion__section]] don't work on dokuwiki page.
They always are transformed to #discussion_section.
Double underscore transforms to single. I found no way to aviod it.
2. The proposed solution:
I don't know how to solve this.
So I propose an addition to actionlink plugin.
Now it has some set of commands, like {{actionlink>index}}.
It's possible to add an ability to make links not changed by dokuwiki, like {{actionlink>/texts}}.
In order to prevent javascript injection, I think it may be enough if we limit possible links so that they should start with "/" or "#".
Thus the new commands for actionlink plugin will be:
#xxxxxx, where xxxxxx is the anchor name on this page;
/xxxxxx, where xxxxxx is the address relative to the server root.
So I modify this part of the original actionlink text:
...
switch($action){
... // other commands are here
default: // not recognized command
if(!isset($title)) $title='';
$renderer->doc .= $title;
return true;
}
$action is the text of command in the actionlink: {{actionlink> $action | $title }}.
Now it will be:
...
switch($action){
...
default:
if(!isset($title)) $title='';
$this_link_start=$action{0}; // the first symbol - is it "/" or "#"?
switch ($this_link_start) {
case '/':
$this_link_prefix='http://'.$_SERVER['SERVER_NAME']; break;
case '#':
$this_link_prefix=''; break;
default: // neither "/" nor "#", so it may be "javascript:", we'll omit that
$renderer->doc .= $title;
return true;
}
$renderer->doc .= '<a href="'.$this_link_prefix.$action.'">'.$title.'</a>';
return true;
}
This way we could call links like /texts relative to server root, and they will work.
We also could call links like #discussion__section, and they will work.
3. My only question is will these ("/" or "#") limitations be enough to prevent javascript injection.
My testing shows that it'll be OK, but I'm not a specialist, I'm newbie in PHP and JS and I don't know about caching etc., so I ask here.
Was it a good idea, if not then why.
Thanx.