This specific issue is fixed by:
https://github.com/discourse/discourse/commit/82ca0e368e8758b463c0c589f649f9bb73fc2d79