[pmwiki-users] Attachment links with square brackets in both the filename and link text

Petko Yotov 5ko at 5ko.fr
Sat Oct 31 18:11:00 CDT 2009


On Saturday 31 October 2009 23:35:24 Maxim wrote:
> On Sat, Oct 31, 2009 at 10:11 PM, Petko Yotov <5ko at 5ko.fr> wrote:
> > On Saturday 31 October 2009 22:32:45 Maxim wrote:
> >> I want to do:
> >>
> >> [[Attach:Filename [x].zip | Link Text [x] ]]
> >
> > You cannot -- brackets, parentheses, and punctuation are not allowed in
> > the names of wiki pages or uploaded files, and trying to allow them could
> > bring more trouble than good.
> >
> > You can use a link like this:
> >  [[Attach:Filename_x.zip | Link Text [x] ]]
> >
> > Clicking on the link will bring you the upload form with the correct
> > filename already selected. You can send a file with any name on your
> > system (like "Filename [x].zip"), it will be renamed to the correct
> > filename ("Filename_x.zip").
>
> The square brackets in attachment names do not cause any problems
> otherwise. It is a fairly large problem for me to not have any
> brackets available, as the downloaded files' names are quite 
> important, and it seems quite restrictive in the case of general
> http:// links. I added those to
> http://www.pmwiki.org/wiki/Test/SquareBracketsInLink and they are even
> more buggy...

I regret that this is a large problem for you. Only they are not buggy, what 
you wrote are just not http:// links. The RFC 3986 is the standard for URIs 
and your examples are out of the definition. The following characters need to 
be percent-encoded in URIs if they are part of filenames :

  ":" / "/" / "?" / "#" / "[" / "]" / "@"
  "!" / "$" / "&" / "'" / "(" / ")"
                  / "*" / "+" / "," / ";" / "="

See http://tools.ietf.org/html/rfc3986#section-2 where you can also learn 
about the percent-encoding.

So, your link should be written correctly this way:
  http://www.example.com/Filename%20%5Bx%5D.zip

> Notice also that [[ Link Text [x] -> Attach:Filename.zip ]] fails.

If you require the [ ] characters in the _text_ part of this type of links, 
you could allow them by adding the following to your config.php :

  Markup('[[->','>[[|',
    "/(?>\\[\\[(.+?)\\s*-+&gt;\\s*)(.*?)\\]\\]($SuffixPattern)/e",
    "Keep(MakeLink(\$pagename,PSS('$2'),PSS('$1'),'$3'),'L')");

Thanks,
Petko



More information about the pmwiki-users mailing list