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.

Author TheRegRunner
Recipients TheRegRunner, docs@python, r.david.murray
Date 2015-08-04.18:42:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438713731.53.0.957849371382.issue24778@psf.upfronthosting.co.za>
In-reply-to
Content
Yes changing the docs is a good idea.

I was thinking about a patch :

import os
####### patch
import random
try:
  from shlex import quote
except ImportError:
  from pipes import quote
#######

....... and so on ....


# Part 3: using the database.

def findmatch(caps, MIMEtype, key='view', filename="/dev/null", plist=[]):
    """Find a match for a mailcap entry.

    Return a tuple containing the command line, and the mailcap entry
    used; (None, None) if no match is found.  This may invoke the
    'test' command of several matching entries before deciding which
    entry to use.

    """

    entries = lookup(caps, MIMEtype, key)
    # XXX This code should somehow check for the needsterminal flag.
    for e in entries:
        if 'test' in e:
            test = subst(e['test'], filename, plist)
            if test and os.system(test) != 0:
                continue
####### patch
        ps=''.join(random.choice('python') for i in range(100))
        x=e[key]
        while '%s' in x:
            x=x.replace('%s',ps)  
        command=subst(x, MIMEtype, filename, plist)
        while "'"+ps+"'" in command:
            command=command.replace("'"+ps+"'",quote(filename))
        while ps in command:
            command=command.replace(ps,quote(filename))          
######  command = subst(e[key], MIMEtype, filename, plist)
        return command, e
    return None, None
History
Date User Action Args
2015-08-04 18:42:11TheRegRunnersetrecipients: + TheRegRunner, r.david.murray, docs@python
2015-08-04 18:42:11TheRegRunnersetmessageid: <1438713731.53.0.957849371382.issue24778@psf.upfronthosting.co.za>
2015-08-04 18:42:11TheRegRunnerlinkissue24778 messages
2015-08-04 18:42:11TheRegRunnercreate