RC RANDOM CHAOS

The breach was the network working as intended

Medium blocked the Polish letter Ś because Windows represented Right Alt+S as Ctrl+Alt+S, colliding with the editor's Ctrl+S handler.

· 3 min read
The breach was the network working as intended

A Medium user could type every Polish letter except Ś. Pressing the correct keys produced nothing, and the failure occurred only inside Medium’s editor.

The immediate cause was a keyboard shortcut handler. Medium intercepted Ctrl+S so that users with an ingrained habit of manually saving documents would not open the browser’s Save dialog. Its editor saved the document and called preventDefault() on the keyboard event:

if ((e.metaKey || e.ctrlKey) && e.keyCode === goog.events.KeyCodes.S) {
  this._editors.save()
  e.preventDefault()
}

That conditional treated every event containing Ctrl+S as a save command. On Windows with the Polish programmer’s keyboard layout, that assumption swallowed a letter.

How Right Alt became Ctrl plus Alt

Polish adds nine diacritics to the Latin alphabet. Early personal computers imported into Poland commonly arrived with American keyboards, so users needed a software convention for entering those characters without modified hardware. The programmer’s layout assigned eight diacritics to their corresponding Latin letters and one to a nearby key, using Alt as the modifier.

Windows also used Alt for keyboard access to menus and dialog controls. Once keyboards had a second Alt key, the layout could reserve Left Alt for Windows shortcuts and use Right Alt for Polish characters.

Compatibility complicated that arrangement. Windows mapped Right Alt internally to the combination Ctrl+Alt so the function remained available with older keyboards that had only one Alt key. As a result, the Right Alt+S sequence used to enter Ś appeared to software as Ctrl+Alt+S.

Medium’s handler checked whether Ctrl was down and whether the key was S. It did not care that Alt was also down. It therefore interpreted the Polish input sequence as Ctrl+S, ran the editor’s save operation, and canceled the event before the character could be inserted.

The browser, operating system, keyboard layout, and editor were each following their configured rules. The failure appeared at the boundary between them, where application code reduced a richer input event to an overly broad shortcut test.

Match the shortcut you actually own

The fix was to handle Ctrl+S only when Alt was absent:

if ((e.metaKey || (e.ctrlKey && !e.altKey)) && e.keyCode === goog.events.KeyCodes.S) {
  this._editors.save()
  e.preventDefault()
}

That additional condition preserved Command+S on macOS and plain Ctrl+S on Windows or Linux while allowing Ctrl+Alt+S to continue through the input system.

For engineers implementing browser shortcuts, the useful distinction is between required modifiers and the complete modifier state. Checking only ctrlKey establishes that Ctrl participated in the event. It does not establish that the user pressed plain Ctrl+S. If the application intends to claim one exact chord, its predicate should reject modifiers that do not belong to that chord.

This matters most in editors, terminals, remote desktops, and other interfaces that receive international text or forward input to another system. Calling preventDefault() is a claim over an input sequence, and broad claims can interfere with keyboard layouts that encode characters through modifiers. Testing only an American layout will not expose those collisions.

The Polish programmer’s layout remained commonly used long after the import restrictions and hardware constraints that produced it had disappeared. Application code therefore had to accommodate a convention inherited from early PCs, combined with a Windows compatibility decision and a save habit formed when storage was slow and unreliable.

The durable part of Medium’s fix was not its size. It was the decision to encode the exception explicitly and document why Alt changes the meaning of Ctrl+S. Without that context, a future cleanup could easily simplify the conditional back into the bug.

Share

Keep Reading

Latest on the Wire

Full wire →

New signal daily · RSS

Stay in the loop

New writing delivered when it's ready. No schedule, no spam.