fix: Unicode characters stripped from generated file names#163
Conversation
Pushpavel
left a comment
There was a problem hiding this comment.
Hi @JoonHyuk0331, great breakdown in the PR. Problem.getDefaultName() is a mistake, we don't need to convert the problem name in showProblemGatheringDialog at all, It anyways is going to be converted based on file extension when the file is getting generated. So, I think just removing Problem.getDefaultName() and using problemNames = MutableList(problems.size) { problems[it].name } should work fine
|
Hi @Pushpavel, I've implemented the requested changes. Could you please review it again? Thanks! |
|
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|




Problem
Problem.getDefaultName()directly calleddefaultConversion, which strips all non-ASCII characters via[^0-9a-zA-Z_]. This bypassed the existing fallback chain ingetValidFileNamethat already supports Unicode throughspecialCharacterFilteringandunicodeWhiteListConversion. As a result, problem names like "한국어 문제 A" became "__A".Space-to-underscore conversion only existed in
defaultConversion(step 3 of the fallback chain). SincespecialCharacterFiltering(step 1) succeeds on all modern OS,getValidFileNamenever reached step 3, leaving spaces unconverted in file names.Root Cause
1->
getDefaultName()calleddefaultConversiondirectly instead of going through thegetValidFileNamefallback chain, makingspecialCharacterFilteringandunicodeWhiteListConversioneffectively dead code for default file name generation.2->
getValidFileNamedelegated space handling entirely todefaultConversion, but spaces are valid path characters, so steps 1 and 2 never threwInvalidPathExceptionand step 3 was never reached.What Changed
File:
DefaultFileGenerator.ktChange:
getValidFileName: protected → internalWhy: Allow
getDefaultName()to call it via instance without duplicating fallback logic. No subclass overrides this method.File:
problemGatheringDialog.ktChange:
getDefaultName(): defaultConversion(name) → DefaultFileGenerator(project).getValidFileName(name)Why: Use the proper fallback chain so Unicode characters are preserved
File:
DefaultFileGenerator.ktChange: Added
name.replace(' ', '_')after fallback chain ingetValidFileNameWhy: Ensure space-to-underscore conversion applies regardless of which fallback step succeeds
Test
Test by using

./gradlew runIde -PplatformType=PC -PplatformVersion=2025.1