Resolve "Wiki: links with spaces in the url render incorrectly with CommonMark"
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?
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
[Documentation created/updated](https://docs.gitlab.com/ee/development/documentation/index.html#contributing-to-docs) -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides