DSK-658 - Support non ascii - #96
Merged
Merged
Conversation
DSK-658: mailcore paths are UTF-8 (fileSystemRepresentation), but the Windows layer used narrow CRT calls (fopen_s, _unlink, _mkdir, stat) that resolve paths through the ANSI codepage. Any path with characters outside the codepage — e.g. a temp dir under a non-ASCII user profile — failed to open, breaking RFC822 temp files (MCOErrorFile) and stalling Outbox. Convert UTF-8 to UTF-16 and call _wfopen_s/_wunlink/_wmkdir/_wstat64i32, falling back to the narrow call when the input is not valid UTF-8. Also route MCDataStreamDecoder and MCCertificateUtils through MCWin32.h so their fopen calls hit the wrapper.
OleksiiShvachenko
force-pushed
the
feature/DSK-658-support-non-ascii
branch
from
August 27, 2026 15:20
5d96348 to
4cc613c
Compare
lxbndr
previously approved these changes
Aug 27, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4cc613c. Configure here.
corecrt_io.h declares POSIX-compat unlink; when io.h is included after MCWin32.h, the unlink macro rewrites that declaration into extern "C" mailcore::win32_unlink and clang-cl rejects the language linkage mismatch. Pre-include io.h (and wchar.h for _wstat64i32) so all CRT declarations of the wrapped names precede the macros, matching how direct.h and sys/stat.h are already handled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dbezverkhnii
approved these changes
Aug 28, 2026
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.

DSK-658: mailcore paths are UTF-8 (fileSystemRepresentation), but the Windows layer used narrow CRT calls (fopen_s, _unlink, _mkdir, stat) that resolve paths through the ANSI codepage. Any path with characters outside the codepage — e.g. a temp dir under a non-ASCII user profile — failed to open, breaking RFC822 temp files (MCOErrorFile) and stalling Outbox.
Convert UTF-8 to UTF-16 and call _wfopen_s/_wunlink/_wmkdir/_wstat64i32, falling back to the narrow call when the input is not valid UTF-8. Also route MCDataStreamDecoder and MCCertificateUtils through MCWin32.h so their fopen calls hit the wrapper.
Note
Medium Risk
Changes core Win32 path handling for fopen, unlink, mkdir, and stat across the library via header macros; incorrect UTF-8 handling or stat layout assumptions could cause subtle file failures on Windows.
Overview
Fixes Windows file I/O when mailcore paths are UTF-8 (
fileSystemRepresentation) but narrow CRT calls (fopen_s,_unlink,_mkdir,stat) interpret them via the ANSI codepage, which broke temp RFC822 files and Outbox on non-ASCII profile paths.win32_fopennow converts paths withMultiByteToWideChar(CP_UTF8, …)and opens via_wfopen_s, with fallback to the existing narrowfopen_swhen conversion fails or the mode string is too long. Newwin32_unlink,win32_mkdir, andwin32_statfollow the same pattern using_wunlink,_wmkdir, and_wstat64i32.MCWin32.h(source and public include) redefinesunlink,mkdir, andstatto those wrappers (alongside the existingfopenmacro), addsio.h/wchar.h, and declares the new helpers.MCDataStreamDecoder.cppandMCCertificateUtils.cppincludeMCWin32.hfirst so theirfopencalls use the wrapper.Reviewed by Cursor Bugbot for commit 72c919b. Bugbot is set up for automated code reviews on this repo. Configure here.