Fix: skip Windows registry MIME entries with an invalid Content Type#17106
Open
SAY-5 wants to merge 1 commit into
Open
Fix: skip Windows registry MIME entries with an invalid Content Type#17106SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Contributor
|
While this is probably the right thing to do, did you encounter a corrupted registry naturally? |
I've reported this bug. Yes, registry corruption were encountered naturally on one of Windows 10 installations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows,
Crystal::System::MIME.loadreads MIME types from the registry and callsMIME.registerfor each.<ext>\Content Typeentry. If any entry holds an empty or malformed value,MIME.registerraisesArgumentError("Invalid media type: ...") which is unrescued, so a single bad registry entry aborts MIME initialization and crashes the firstMIME.from_extensioncall.The Unix loader already guards each source with a bare
rescue(src/crystal/system/unix/mime.cr). This mirrors that: the per-entryregisteris wrapped so an invalid entry is skipped instead of taking down the whole load.Fixes #17103.
The failing path is Windows-registry-specific, so I couldn't add a portable spec that exercises
loaddirectly. I confirmed the behavior of the guarded loop with the same callloadmakes (registering a batch where one entry has an empty Content Type): before the guard theArgumentErroraborts the loop, after it the bad entry is skipped and the remaining extensions register.