Skip to content

Resolve "Wiki: links with spaces in the url render incorrectly with CommonMark"

Brett Walker requested to merge 48869-wiki-slugs-with-spaces into master

What does this MR do?

CommonMark does not support links with spaces in the same way that Redcarpet does:

markup CommonMark Redcarpet
[example](example.com) <a href="example.com">example</a> <a href="example.com">example</a>
[example](with space) [example](with space) <a href="with%20space">example</a>

Specifically, the text with spaces in the link portion is valid in Redcarpet, with the spaces encoded. CommonMark does not treat the link portion as a valid link.

Since Gitlab treats links with spaces as valid, they can be used to reference a wiki page. So [page](this page) would create something like <a href="http://localhost:3000/twitter/typeahead-js/wikis/this%20page">page</a> and it gets routed to the correct wiki page with slug this-page. This no longer works since CommonMark does not render it as a valid link.

We now add a filter, Banzai::Filter::SpacedLinkFilter, that finds any such invalid links and makes them valid. Only used for wikis so that normal file rendering continues to conform to the CommonMark spec.

What are the relevant issue numbers?

#48975 (closed)

Does this MR meet the acceptance criteria?

Edited by Brett Walker

Merge request reports