diff options
author | Stan Hu <stanhu@gmail.com> | 2019-02-19 22:21:30 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-02-22 00:05:19 -0800 |
commit | d2c2a0627fe6e76b7c3a564d99f9c949a48db50a (patch) | |
tree | e8e2fc3869aa19fdbf62ed8ba9d945cd60129b99 /lib/api/project_templates.rb | |
parent | 7ff0c8ae57e6a88c86afae4f8e08bfacfb34d761 (diff) | |
download | gitlab-ce-d2c2a0627fe6e76b7c3a564d99f9c949a48db50a.tar.gz |
Fix 404s when C++ .gitignore template selected
Due to a overly-stringent regex, the project template API was 404'ing
when C++ was requested as the template. Loosen the regex to allow `+`
and `%` for URL-encoded characters.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/57857
Diffstat (limited to 'lib/api/project_templates.rb')
-rw-r--r-- | lib/api/project_templates.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/api/project_templates.rb b/lib/api/project_templates.rb index d05ddad7466..119902a189c 100644 --- a/lib/api/project_templates.rb +++ b/lib/api/project_templates.rb @@ -36,7 +36,10 @@ module API optional :project, type: String, desc: 'The project name to use when expanding placeholders in the template. Only affects licenses' optional :fullname, type: String, desc: 'The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses' end - get ':id/templates/:type/:name', requirements: { name: /[\w\.-]+/ } do + # The regex is needed to ensure a period (e.g. agpl-3.0) + # isn't confused with a format type. We also need to allow encoded + # values (e.g. C%2B%2B for C++), so allow % and + as well. + get ':id/templates/:type/:name', requirements: { name: /[\w%.+-]+/ } do template = TemplateFinder .build(params[:type], user_project, name: params[:name]) .execute |