Leading Space Stripped from Markdown
Summary
Leading spaces on the first line of a markdown comment or description are stripped. This breaks markdown features that allow/require leading whitespace.
Steps to reproduce
- Create a comment starting with a list (" - Test\n - Test\n - Test")
What is the current bug behavior?
The preview looks correct, but the markdown gets saved without the leading space, and the list depth renders incorrectly.
What is the expected correct behavior?
The markdown should be saved without any processing, and the rendered list should match the preview.
Relevant logs and/or screenshots
New comment:
Saved comment:
Output of checks
This bug happens on GitLab.com
Possible fixes
This issue only occurs during comment/description creation, so I suspect it is caused by the slash command extractor.
https://gitlab.com/gitlab-org/gitlab-ce/blob/5a002723/lib/gitlab/slash_commands/extractor.rb#L49
It is trying to clean up the whitespace and newlines left behind by the removing the slash commands, but String#strip
is much too aggressive.
The commands_regex
expression should capture the whitespace around the command so that it is removed during the gsub
replacement.