Service Desk email get rejected when you use a project suffix
Summary
When I declare a "Project name suffix" (for example "support") And then write an E-Mail to contact-project+<user/group>--support@incoming.gitlab.com it gets rejected
Steps to reproduce
Steps to reproduce
- create a project
- enable service desk
- declare a "Project name suffix"
- send an email to the new generated address (contact-project+<user/group>--support@incoming.gitlab.com) to create a ticket
What is the current bug behavior?
Email get's rejected:
Unfortunately, your email message to GitLab could not be processed.
We couldn't find the project. Please check if there's any typo.
What is the expected correct behavior?
Service Desk creates a new ticket/ issue
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Why is this happening
In ServiceDeskHandler
when we see there is a matching project key, we try to find a project by it project = Project.find_by_service_desk_project_key(match[:key])
. But the project_key
is not unique across projects therefore incorrect project can be found. Afterwards, valid_project_key?(project, match[:slug])
will return false
which is correct as incorrect project has been found.
We should ideally search project by its full_path
. But we get the path in the slug
form so it is not that easy.
We use Gitlab::Utils.slugify
method for that. With this method, eg. group/test-one
and group/test/one
paths will be resulting to the same string group-test-one
.