I fixed this bug today.
https://github.com/discourse/discourse/commit/389a0e1a1cf4069703a226d842fd9524a54042bd