GitLab's Wiki uploaded filename can be too long for Git checkout

Summary

GitLab's wiki allows to upload files with very long file name which prevent the wiki repository from being checked-out using git on Windows.

Steps to reproduce

  1. Copy some text from Microsoft OneNote application
  2. Paste it into a Wiki page in GitLab
  3. Save the changes or cancel them: as soon as the paste is done, the upload commit is created in Wiki's git history
  4. Try to checkout / pull the Wiki repository on a windows machine (W10 in my case)

I'm actually not sure what is the behaviour on different host machine when trying to checkout/pull the repo. I've tried to do it using Windows CMD, git Bash and Cygwin on my W10 machine but I always have the same problem.

Example Project

I've created a Wiki page on a dedicated test project on my personnal space

I was able to reproduce the problem using both SSH and HTTPS. Simply try to clone the wiki repository using https or SSH

image

What is the current bug behavior?

The problem is that the paste "image" takes automatically the name of the text cell coming from OneNote. I know for a fact that copying a text cell from OneNote will be interpreted differently depending on the tool to which it's being copied. Notepad++ will get it as text while paint will take it as a picture. GitLab somehow get it as both at the time since it uploads an image AND assign it a name with the content of the OneNote cell...

The problem is that once the paste is done, a git commit is automatically done to store the uploaded image, whatever if we cancel the wiki page edition or not.

What is the expected correct behavior?

From my POV, there are many ways to solve this:

  • limiting the filename length when uploading something
  • by not taking the uploaded content as filename by default
  • ...

Relevant logs and/or screenshots

See above

Output of checks

Not sure what to provide in this section...

Results of GitLab environment info

System information
System:
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   2.5.3p105
Gem Version:    2.7.6
Bundler Version:1.16.6
Rake Version:   12.3.2
Redis Version:  3.2.12
Git Version:    2.18.1
Sidekiq Version:5.2.3
Go Version:     unknown

GitLab information
Version:        11.7.0-ee
Revision:       c02f0d4
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     postgresql
DB Version:     9.6.11
URL:            https://gitlab.ertosgener
HTTP Clone URL: https://gitlab.ertosgener/some-group/some-project.git
SSH Clone URL:  git@gitlab.ertosgener:some-group/some-project.git
Elasticsearch:  no
Geo:            no
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        8.4.4
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
Hooks:          /opt/gitlab/embedded/service/gitlab-shell/hooks
Git:            /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 8.4.4 ? ... OK (8.4.4)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ...
3/1 ... yes
3/4 ... yes
3/5 ... yes
7/10 ... yes
3/11 ... yes
3/13 ... yes
3/14 ... yes
3/15 ... yes
2/16 ... yes
2/17 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.3.5 ? ... yes (2.5.3)
Git version >= 2.18.0 ? ... yes (2.18.1)
Git user has default SSH configuration? ... yes
Active users: ... 9
Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished


Checking GitLab subtasks ... Finished

Possible fixes

N/A