Fix JSON generation bug with tab delimiters in MIME types parser #6
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.
Problem
The JSON generator was incorrectly parsing MIME type files that contain multiple tab delimiters between the MIME type and file extensions. This is a common format in Apache's
mime.typesfile.For example, the line:
Was incorrectly generating:
Instead of the correct output:
This resulted in MIME type values containing tab characters and partial extension names, and missing entries for extensions that should have been parsed.
Root Cause
The bug was in the
ParseMimeTypesListingmethod inManagedCode.MimeTypes.Sync/Program.csat line 148:This code appears to split on both space and tab characters, but actually uses an incorrect method signature. The
Split(char, char, StringSplitOptions)overload doesn't exist - instead, this resolves toSplit(char separator, int count, StringSplitOptions options)where the secondcharparameter is implicitly converted to anintcount/limit parameter.As a result, the split only used space as a delimiter, leaving all tab characters in the first part of the split result.
Solution
Changed to use the correct
Splitsignature with a character array:This ensures both space and tab characters are properly recognized as delimiters when parsing MIME type files.
Testing
atcandacutc) are now correctly mapped to the same MIME typeAdditional Changes
*.trxto.gitignoreto exclude test result files from version controlFixes the issue reported in the original bug report referencing PR #4.
Original prompt
Fixes #5
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.