Repository navigation
fix(i18n): an image URL that fails must not report it in Chinese - #220
Merged
Merged
Conversation
errorBadImageUrl is an ordinary vendor locale key -- all 45 locale files carry a translation, and the editor reads it when the engine raises UplImageUrl, which is what an inserted image URL that 404s or fails CORS produces. The offline build's Offline controller then overwrites it on the controller instance inside loadDocument with a hardcoded Chinese sentence, so every user of this site saw Chinese there in all seven languages -- and the sentence advises configuring editorConfig.imageProxy, which our users cannot reach and which we deliberately do not set. Guard 13 captures whatever the locale merge left on the prototype and replaces the property with an accessor whose setter swallows exactly that literal; every other write goes through, so a vendor upgrade that reworded the message legitimately still wins. If loadDocument already ran, the instance's own copy is deleted so reads fall through. If the locale fetch has not resolved the guard reports "not yet" rather than pinning an empty string. Reverse-validated: with the guard commented out of iframe-guards.ts both E2E cases fail on the Chinese literal. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MKNHFQ1kek1cHeqhbH37Pk
chaxus
enabled auto-merge (rebase)
September 12, 2026 05:40
Deploying document with
|
| Latest commit: |
afec023
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://30f09892.document-7hm.pages.dev |
| Branch Preview URL: | https://fix-bad-image-url-locale.document-7hm.pages.dev |
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.
What users saw
Insert a picture by URL, have the fetch fail (404, or a host that sends no CORS headers), and the editor reports:
In all seven site languages. And it advises configuring
editorConfig.imageProxy— not a knob our users can reach, and one we deliberately do not set (it would route their image URLs through a third party).Found while reading the vendor for #219.
Why
errorBadImageUrlis an ordinary vendor locale key; all 45 locale files translate it (en: "Image URL is incorrect",ja: 画像のURLが正しくありません,ko: 이미지 URL이 잘못되었습니다.). The usual l10n idiom folds those onto<NS>.Controllers.Main.prototype, and the editor readsthis.errorBadImageUrlonAsc.c_oAscError.ID.UplImageUrl.The offline build's
Offlinecontroller — the same patch that supplies the in-process server responder — overwrites it on the instance insideloadDocument, shadowing the translated prototype value.documenteditor/spreadsheeteditor/presentationeditorall carry it (plus theirie/twins);pdfeditordoes not.Fix
Not to translate the sentence — the vendor already translated the original into more languages than we ship. Guard 13 captures the locale value and puts an accessor on the prototype whose setter swallows exactly that one literal:
Every other write goes through, so a vendor upgrade that reworded the message legitimately still wins. If
loadDocumentalready ran, the instance's own copy is deleted. If the locale fetch has not resolved yet, the guard reports "not yet" and the guard timer re-applies — it can never leave the property emptier than it found it.Deliberately not done: setting
editorConfig.imageProxy. It would make cross-origin image insertion work — by sending the URL, and the user's interest in it, to whoever runs the proxy. Product decision, not a bug fix.Tests
test/e2e/bad-image-url-locale.spec.ts— opens a real docx and a real xlsx, reads the property the error handler reads off the live controller.test/unit/vendor-bad-image-url.test.ts— pins the vendor side: the three apps still assign exactly the literal the guard matches, and the translated original is still present inen.jsonand every language the site ships.Reverse validation (convention 5): with
installBadImageUrlGuardcommented out, both E2E cases fail withExpected: not "无法加载图片…".🤖 Generated with Claude Code
https://claude.ai/code/session_01MKNHFQ1kek1cHeqhbH37Pk