Skip to content

gh-159428: Don't read mimetypes.knownfiles by default on Windows - #159445

Merged
zooba merged 2 commits into
python:mainfrom
cjames23:gh-159428-mimetypes-windows
Oct 15, 2026
Merged

zooba merged 2 commits into
python:mainfrom
cjames23:gh-159428-mimetypes-windows

Conversation

@cjames23

@cjames23 cjames23 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Make knownfiles empty on Windows so that only the registry is used by default. Files passed to init() or assigned to knownfiles explicitly are still read.

The default knownfiles are POSIX paths such as /etc/mime.types. On Windows these resolve against the root of the current drive (e.g. C:\etc\mime.types), a location that unprivileged users can usually create.

Make knownfiles empty on Windows so that only the registry is used by default. Files passed to init() or assigned to knownfiles explicitly are still read.
@sethmlarson

sethmlarson commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

cc @zooba @python/windows-team as you commented on the PSRT email thread, too.

@sethmlarson sethmlarson added the type-security A security issue label Oct 15, 2026

@zooba zooba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change to move the comment, but looks good to me

Comment thread Lib/mimetypes.py Outdated
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@zooba zooba added OS-windows needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 15, 2026
@zooba
zooba merged commit 04a29bf into python:main Oct 15, 2026
65 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @cjames23 for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12, 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @cjames23 and @zooba, I could not cleanly backport this to 3.13 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 04a29bf8f9ff8526cd96cb7368400173303a390a 3.13

@bedevere-app

bedevere-app Bot commented Oct 15, 2026

Copy link
Copy Markdown

GH-159489 is a backport of this pull request to the 3.15 branch.

@cjames23
cjames23 deleted the gh-159428-mimetypes-windows branch October 15, 2026 21:03
@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 15, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @cjames23 and @zooba, I could not cleanly backport this to 3.12 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 04a29bf8f9ff8526cd96cb7368400173303a390a 3.12

@bedevere-app

bedevere-app Bot commented Oct 15, 2026

Copy link
Copy Markdown

GH-159490 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 15, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @cjames23 and @zooba, I could not cleanly backport this to 3.11 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 04a29bf8f9ff8526cd96cb7368400173303a390a 3.11

@cjames23
cjames23 restored the gh-159428-mimetypes-windows branch October 15, 2026 21:04
@zooba

zooba commented Oct 15, 2026

Copy link
Copy Markdown
Member

I can't do the backports right now - might have a chance tomorrow, but if someone else wants to do them then go ahead.

@cjames23

Copy link
Copy Markdown
Contributor Author

I will do the backports tomorrow for the remaining branches

zooba pushed a commit that referenced this pull request Oct 16, 2026
…ws (GH-159445)

Make knownfiles empty on Windows so that only the registry is used by default. Files passed to init() or assigned to knownfiles explicitly are still read.
(cherry picked from commit 04a29bf)

Co-authored-by: Cary Hawkins <hawkinscary23@gmail.com>
zooba pushed a commit that referenced this pull request Oct 16, 2026
…ws (GH-159445)

Make knownfiles empty on Windows so that only the registry is used by default. Files passed to init() or assigned to knownfiles explicitly are still read.
(cherry picked from commit 04a29bf)

Co-authored-by: Cary Hawkins <hawkinscary23@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes OS-windows type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants