When a post contains an image with an underscore in the filename (e.g. ), each save of
the post doubles the backslashes before the underscore in the raw content:
- After 1st edit: ![20260421_140231|…]
- After 2nd edit: ![20260421\_140231|…]
- After Nth edit: ![20260421{2^N}_140231|…]
After 17 edits the raw field accumulated 131,072 backslash characters (2^17), growing from ~8KB to ~136KB. This eventually
causes the post to become uneditable — the composer reports a character count far exceeding max_post_length even though the
visible content is small.
Steps to reproduce:
- Upload an image whose filename contains an underscore.
- Insert it into a post. Discourse generates alt text like 20260421_140231.
- Edit and save the post repeatedly (5–10 times is enough to notice growth).
- Inspect the raw via /posts/{id}.json — backslash count doubles on each save.
Expected behavior: The raw content should remain stable across edits. Underscores in image alt text should not be re-escaped on
every save.
Actual behavior: Each save multiplies the backslashes before _ in image alt text by 2.
Workaround: Run the following in the Rails console to strip the excess backslashes and rebake:
p = Post.find(POST_ID)
p.update_column(:raw, p.raw.gsub(/\+(?=_)/, “”))
p.rebake!
Environment:
- Discourse version: 2026.4.0-latest
- Installed via official ./launcher Docker setup