I completely misread this code and there was no bug. In fact yesterday's fix broke it. Revert.
Attach a file by drag & drop or click to upload