fix(web): localize macOS native picker prompts via session locale (#228)#231
Merged
Conversation
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.
Summary
Localizes the macOS native folder/file picker prompts in the configure UI (#228). The prompts were hardcoded English AppleScript constants; they now come from a locale-keyed catalog (en/ja) selected by the server-side session locale — the zero-injection design is unchanged.
Design
mureo/web/native_picker.py:_MACOS_DIR_SCRIPT/_MACOS_FILE_SCRIPTbecome_MACOS_DIR_SCRIPTS/_MACOS_FILE_SCRIPTSdicts keyed"en"/"ja". Every prompt stays a hardcoded constant — no client value is ever interpolated into the AppleScript.pick_directory/pick_filegain a keyword-onlylocale: str = "en"; unknown locales fall back toen.mureo/web/handlers.py:_post_pick_directory/_post_pick_fileforwardlocale=self.wizard.session.locale. The session locale is only settable throughPOST /api/localewith an{"en","ja"}allow-list, so the value is provably never client text.title, which already worked.Security
The injection posture is unchanged and re-pinned by tests: the osascript
-ebody is byte-identical per locale regardless of the client title, a hostile title never reaches argv on darwin, and alocalefield smuggled into the request body cannot override the session locale (tested on both routes).Test plan
tests/test_web_native_picker.py—TestMacOSLocaleKeyedPrompts(en default, ja prompts for dir/file, unknown-locale fallback, constant-per-locale body, hostile-title re-check under ja, catalog key set) +TestLocaleKwargNonDarwintests/test_web_handlers.py— locale forwarding on both pick routes + body-smuggling negative testsCloses #228