Skip to content

Fix issue with non-ASCII wiki TOC links

Oren Kanner requested to merge orenyk/gitlab:26210-toc-links-v2 into master

What does this MR do?

Resolves an issue where wiki table of contents links would be rendered as external links (target="_blank") if they contained non-ASCII characters. This was caused by the combination of two factors:

  1. The ExternalLinkFilter treats all links as external by default and is only skipped if a link is determined to be internal.
  2. The ExternalLinkFilter uses URI.parse to check if a link is valid. Links that are determined to be invalid will fail the check to see if they are internal as well.

This was fixed by modifying the TableOfContentsFilter to encode the href attribute using CGI.escape, which can successfully be parsed by URI.parse. My first approach was to modify ExteranlLinkFilter but this felt more appropriate since it was more limited in scope.

I am not sure if a bugfix like this requires any changes to documentation. I updated the unit tests for TableOfContentsFilter to handle this case but was not sure if higher-level testing was necessary.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team

#26210 (closed)

Edited by Bob Van Landuyt

Merge request reports