Skip to content

Wiki doesn't handle "~" in page paths correctly

Summary

When using a ~ in a wiki page title, we create a ~ directory in the wiki repository and store the page there, but the ~ is expanded to the GitLab user's home directory /var/opt/gitlab in some situations.

Steps to reproduce

  1. Create a wiki page with the title ~/test and some content.

What is the current bug behavior?

  • In the wiki sidebar navigation, the page's directory gets displayed as var/opt/gitlab.
  • Opening the page uses the expanded directory in the URL.
  • When trying to delete the page, GitLab aborts with a 503 error.
  • When trying to edit the page, GitLab responds with a validation error Someone edited the page the same time you did.

What is the expected correct behavior?

  • We should never expand ~ into the home directory, and display it as a literal ~ instead.
  • Editing and deleting a page with ~ in the path or title should work without errors.

Relevant logs and/or screenshots

Customer ticket: https://gitlab.zendesk.com/agent/tickets/148330

Wrong path in sidebar:

image

Output of checks

This bug happens on GitLab.com

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

Edited by Markus Koller