Mattermost crashes when posting a code snippet containing white space

Summary

When posting a code snippet including a whitespace line, Mattermost crashes on both the desktop and browser.

Steps to reproduce

v4.4.1
Add a code snippet with a blank line, e.g. this will fail:
`curl -X POST
https://IAM.A.URL:8088
-H 'Authorization: ’
-H ‘Cache-Control: no-cache’
-H ‘Content-Type: application/json’
-d '{
“key1”: “value1”,
“key2”: “value2”,
“key3”: “value3”,
“key4”: “value4”

}’`

But this succeeds:
curl -X POST \ https://IAM.A.URL:8088 \ -H 'Authorization: <TOKEN>' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -d '{ "key1": "value1", "key2": "value2", "key3": "value3", "key4": "value4" }'

Expected behaviour

The code snippet is correctly formatted regardless of whitespace.

Observed behaviour

The browser windows grinds to a halt and the Mac desktop app crashes (requires restart).

Thanks for the report @Niko,

I’ve reproduced your issue on our nightly build server running the latest master and have created this ticket to track.