New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set #54132
Comments
mailcap.getcaps() has a call to mailcap.listmailcapfiles(), which returns a list of all mailcap files found on the system. listmailcapfiles() first looks for the MAILCAPS environment variable. If it exists, it converts the string value into a list by splitting it on ":". This will not work on platforms that use other path separators, like Windows (";"). Attached are patches that use os.pathsep instead. For more information about the MAILCAPS variable, see Appendix A in RFC 1524 (http://tools.ietf.org/html/rfc1524.html). |
Fixing typo in title |
Thanks for the patches. Can you also add a test case to Lib/test/mailcap.py to cover this problem? |
I'm also creating a test for mailcap (bpo-6484), which is how I found this bug. I'll have an update to that test submitted soon once I implement r.david.murray's helpful suggestions. |
I just submitted new versions of test_mailcap.py in case 6484. |
BTW, is there a real use case that lead you to open this report, or is it just theoretical? I’m not even sure mailcap is used on non-UNIX (and even there, I think it’s not used by recent tools). |
It's just theoretical. A web search shows that a few Windows programs, like PC Pine, can use $MAILCAPS. But none of those tools look recent, like you said. |
Okay. Nonetheless, splitting on os.sep doesn’t cost us anything and is IMO a good practice to follow. |
New changeset 7b83d2c1aad9 by Nick Coghlan in branch 'default': |
As noted in the commit message, I didn't backport this, since it didn't seem worth risking breaking even the unlikely case that someone actually *was* using the MAILCAP environment variable on Windows. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: