[pmwiki-users] Local windows files and unix
Patrick R. Michaud
pmichaud at pobox.com
Mon Feb 7 20:10:28 CST 2005
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.
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 :-).
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. :-)
Pm
More information about the pmwiki-users
mailing list