Skip to content

User/Group sites with mixed case path have incorrect Pages URL

Summary

If we have user website for Pages that has mixed case path (e.g. SomeUser.gitlab.io) then

  1. The domain name it's expected to be served on (https://someuser.gitlab.io) will be returning 404 Not Found
  2. Under Settings / Pages there will be wrong URL displayed (https://someuser.gitlab.io/SomeUser.gitlab.io)

1. happens only if Pages is configured to use the API domain config source and not the disk one (which is the case on GitLab.com).

The reason is that Project#pages_group_url is downcased - https://gitlab.com/gitlab-org/gitlab/-/blob/e968773fd5a3388c3ddb9196fab38d375508ac98/app/models/project.rb#L1697, while in Project#pages_url we do not downcase the path when comparing - https://gitlab.com/gitlab-org/gitlab/-/blob/e968773fd5a3388c3ddb9196fab38d375508ac98/app/models/project.rb#L1700-1708.

See !34976 (comment 366121058).

Steps to reproduce

  1. Create project for Pages user site with mixed case path (e.g. SomeUser.gitlab.io).
  2. Deploy Pages for this project

Example Project

https://gitlab.com/jaimemartinez/JaimeMartinez.gitlab.io

What is the current bug behavior?

  1. Under Settings / Pages the URL for Your pages are served under will be https://someuser.gitlab.io/SomeUser.gitlab.io instead of https://someuser.gitlab.io.
  2. https://someuser.gitlab.io will return 404 Not found (if Pages is configured to use the API config source).

What is the expected correct behavior?

  1. Under Settings / Pages the URL for Your pages are served under should be https://someuser.gitlab.io.
  2. https://someuser.gitlab.io should respond with 200 OK and serve the actual site.

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.)

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

We need to downcase project's path when generating pages_url:

  def pages_url
    url = pages_group_url
-   url_path = full_path.partition('/').last
+   url_path = full_path.partition('/').last.downcase

    # If the project path is the same as host, we serve it as group page
    return url if url == "#{Settings.pages.protocol}://#{url_path}"

    "#{url}/#{url_path}"
  end  
Edited by Krasimir Angelov