[pmwiki-users] Local windows files and unix

Martin Fick fick at fgm.com
Thu Feb 10 11:11:39 CST 2005


On Mon, Feb 07, 2005 at 08:10:28PM -0600, Patrick R. Michaud wrote:
> On Mon, Feb 07, 2005 at 08:09:02PM -0500, Martin Fick wrote:
> > On Mon, Feb 07, 2005 at 07:29:06PM -0500, Neil Herber wrote:
> > > At 2005-02-07  06:57 PM -0500, Martin Fick is rumored to have said:
> > > >First, is there anyway to make PmWiki recognize windows file
> > > >URLs such as \\fileserver\fil?  In other words, automatically
> > > >detect such URLs in plain text and mark them up as links?
> > > 
> > I've noted the security concern with various browsers.  
> > 
> > As for my request, I think I need to clarify.  I would like
> > plain text without the file: prefix to be recognized as a
> > URL if there are backslashes in it.  
> 
> In what has to be one of the most bizarre regular expressions I've
> ever written...try adding the following to your config.php:
> 
> $UrlExcludeCharsWin = str_replace('\\\\', '', $UrlExcludeChars);
> Markup('\\\\server\file', '<wikilink',
>   "/\\\\\\\\\\w+\\\\[^\\s$UrlExcludeCharsWin]*[^\\s.,?!$UrlExcludeCharsWin]/e",
>   "Keep(MakeLink(\$pagename, 'file:///'.str_replace('\\\\\\','%5c','$0'), 
>     '$0'), 'L')");
> 
> (Yes, that's right, there are *ten* backslashes at the beginning of that
> string.  Isn't Windows fun? :-)
> 
> This converts urls of the form "\\server\file" into file:/// links.


That works great, thanks!


> So far it only works with "bare" \\server\file links -- i.e., it
> doesn't understand [[\\server\file | link text]] (let me know if you
> need this -- I'm sure it'll somehow be even more bizarre :-).


Actually, now that you mention it, that would be nice too. :)
I couldn't figure it out myself.  Would it make sense to somehow
make link formats easily custmoizable in config.php also?


> I have this particular modification available for demonstration
> at http://www.pmwiki.org/wiki/Test/WindowsFileUrls .
> 
> I tested it under both IE 6 and Firefox 1.0 and it appears to work okay.
> Under Firefox I had to set the server.checkloaduri property to get it
> to accept file: links (as discussed previously).  Surprisingly, I didn't
> appear to have to do anything to get IE 6 to accept the file: links to
> another server, even though it wouldn't let me access files on the local
> server.  Sounds like another IE security hole.  :-)

May I as why the 3 slashes after file?  

file:///server/file

instead of simply

file://server/file

which seems to work for me?


  -Martin



More information about the pmwiki-users mailing list