This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: pydoc insists upon producing file: URLs
Type: enhancement Stage:
Components: Demos and Tools Versions: Python 3.2
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, doko, eric.araujo, r.liebscher, ron_adam
Priority: normal Keywords:

Created on 2004-02-22 09:29 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg60465 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-02-22 09:29
[forwarded from]

In method docmodule() of class HTMLdoc, a href is
produced to the source code of the current module.

First of all, it is produced as a file: URL, so it is
incorrect on any computer other than the server.

Second, it is a minor security breach, because it
displays information about the directory structure of
the computer on which it is running.

Now, normally, you'd run pydoc so that it would only
serve files locally, and the current behavior is not
too bad.  However, the program ought to be made more
flexible so that it can also be used in other ways.

I'd suggest replacing this line:

            filelink = '<a href="file:%s">%s</a>' %
(url, path)

with a function call, so that the behavior of the
program can be easily modified:

	    filelink = source_code_link(url, path)

def source_code_link(url, path):

One could then make the behavior of source_code_link()
controllable from the command line via a global
variable, or just let people who want to modify the
behavior simply replace source_code_link() with their
own function.
msg65445 - (view) Author: Ron Adam (ron_adam) * Date: 2008-04-13 14:06
The following patch also fixes this along with other improvements. 
Maybe someone can review it.
msg75324 - (view) Author: René Liebscher (r.liebscher) Date: 2008-10-29 18:06
I would like to see this change introducing a method of class HTMLDoc.

It has already some such methods as:

    def namelink(self, name, *dicts):
    def classlink(self, object, modname):
    def modulelink(self, object):
    def modpkglink(self, data):

So it would be logically to make it a method 
    def filelink(self,url,path):
         """Make a link to source file."""
         return '<a href="file:%s">%s</a>' % (url, path)
and changing the creating of the filelink to
            filelink = self.filelink(url, path)
         except TypeError:
            filelink = '(built-in)'

This way one can easily subclass HTMLDoc for own purposes and define a
own filelink method.
msg114325 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-19 06:07
Closed as a duplicate of #2001, but please keep in mind msg75324.
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39970
2010-08-19 06:07:03BreamoreBoysetstatus: open -> closed

nosy: + BreamoreBoy
messages: + msg114325

resolution: duplicate
2010-07-10 23:30:37terry.reedysetversions: + Python 3.2, - Python 2.6
2010-02-16 05:38:55eric.araujosetnosy: + eric.araujo
2008-10-29 18:06:41r.liebschersetnosy: + r.liebscher
messages: + msg75324
2008-04-13 14:06:18ron_adamsetnosy: + ron_adam
messages: + msg65445
2008-04-12 13:55:03ajaksu2setversions: + Python 2.6
2004-02-22 09:29:59dokocreate