Fix issue with non-ASCII wiki TOC links
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:
- The ExternalLinkFilter treats all links as external by default and is only skipped if a link is determined to be internal.
- 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
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Performance and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
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