Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot upload jar file #7266

Closed
1 of 6 tasks
tomposmiko opened this issue Jun 20, 2019 · 19 comments · Fixed by #12465
Closed
1 of 6 tasks

Cannot upload jar file #7266

tomposmiko opened this issue Jun 20, 2019 · 19 comments · Fixed by #12465
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@tomposmiko
Copy link

  • Gitea version (or commit ref): 1.8.3
  • Operating system: Ubuntu 18.04
  • Database (use [x]):
    • PostgreSQL
    • [ x] MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

Despite this setting:
ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

I does not allow upload jar files.
If I set /, then the upload is allowed.

application/* also does not allow me to do that.

What should be the appropriate setting?
...

Screenshots

@PedroAS7
Copy link

PedroAS7 commented Aug 8, 2019

application/java-archive not working on Gitea 1.9.0 either

@lunny lunny added the type/bug label Aug 9, 2019
@tomposmiko
Copy link
Author

What is the severity of this issue from your perspective?

@lunny
Copy link
Member

lunny commented Aug 16, 2019

Where did you upload? Releases or issues?

@lunny lunny added type/question Issue needs no code to be fixed, only a description on how to fix it yourself. and removed type/bug labels Aug 16, 2019
@lunny
Copy link
Member

lunny commented Aug 16, 2019

There are two allowed_types, you may changed the wrong section. I uploaded successfully on my local instance both the releases and issues.

[repository.upload]
ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|application/java-archive"

[attachment]
ALLOWED_TYPES = "application/zip|application/gzip|application/x-gzip|application/x-gtar|application/x-tgz|application/x-compressed-tar|application/java-archive"

@tomposmiko
Copy link
Author

Where did you upload? Releases or issues?

releases

@tomposmiko
Copy link
Author

Hmm, this is interesting.

$ mkdir -p data/tmp/uploads
$ chown ...
$ service gitea restart

And it starts working.
However, after second restart, it stops working, because the tmp directory is gone!
In fact I investigated the following scenarios:

  1. no [repsitory.upload] section in app.ini
    -> no success, even if the directory is created.

[repository.upload]
ENABLED = true
TEMP_PATH = data/tmp/uploads
FILE_MAX_SIZE = 3
MAX_FILES = 5
ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

It works after first service restart if the directory is created. It does not work after the second restart, the tmp directory is gone.

  1. [repository.upload]
    ENABLED = true
    TEMP_PATH = /data/gitea/data/tmp/uploads
    FILE_MAX_SIZE = 3
    MAX_FILES = 5
    ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

Directory created, service restarted.
No success

  1. TEMP_PATH = tmp/uploads
    Directory created, service restarted.
    No success

So I got lost, I have no idea

@lafriks
Copy link
Member

lafriks commented Aug 24, 2019

You should try mount tmp as volume in docker

@tomposmiko
Copy link
Author

I don't use docker.

@tomposmiko
Copy link
Author

Hmm, this is interesting.

$ mkdir -p data/tmp/uploads
$ chown ...
$ service gitea restart

And it starts working.
However, after second restart, it stops working, because the tmp directory is gone!
In fact I investigated the following scenarios:

  1. no [repsitory.upload] section in app.ini
    -> no success, even if the directory is created.

[repository.upload]
ENABLED = true
TEMP_PATH = data/tmp/uploads
FILE_MAX_SIZE = 3
MAX_FILES = 5
ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

It works after first service restart if the directory is created. It does not work after the second restart, the tmp directory is gone.

  1. [repository.upload]
    ENABLED = true
    TEMP_PATH = /data/gitea/data/tmp/uploads
    FILE_MAX_SIZE = 3
    MAX_FILES = 5
    ALLOWED_TYPES = image/jpeg|image/png|application/zip|application/gzip|application/java-archive

Directory created, service restarted.
No success

  1. TEMP_PATH = tmp/uploads
    Directory created, service restarted.
    No success

So I got lost, I have no idea

@tomposmiko
Copy link
Author

Is it a bug or do I miss something?

@sapk
Copy link
Member

sapk commented Aug 28, 2019

Gitea should support upload of java archive so it must be a configuration or system problem.
To be able to debug, do you have any log of the failed upload ?

@stale
Copy link

stale bot commented Oct 27, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Oct 27, 2019
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Nov 2, 2019
@stale stale bot removed the issue/stale label Nov 2, 2019
@reikjarloekl
Copy link

reikjarloekl commented Jan 14, 2020

I have the same issue but with .zip files. Can be reproduced on try.giteo.io using a Windows 10 PC and Chrome or Firefox.
It works using iOS! So apparently, mime type is set differently/ incorrectly using Windows 10/ Chrome or Firefox?

2020-01-14 21_09_59-Release aktualisieren - test - Gitea_ Git with a cup of tea - https___try gitea

@sapk
Copy link
Member

sapk commented Jan 14, 2020

Yes, It is possible that browser/os use different value. You can debug the mime type in gitea log or with the network inspector on firefox and chrome.
For Chrome: https://developers.google.com/web/tools/chrome-devtools/network#load

@reikjarloekl
Copy link

There is no activity in the network tab. Possibly the javascript is already blocking the file from being uploaded?

@sapk
Copy link
Member

sapk commented Jan 14, 2020

You need to open the network tab before uploading the file

@reikjarloekl
Copy link

I did...

gitea-upload-invalid-type

@zeripath
Copy link
Contributor

It'll be dropzone.js that is blocking the zip directly.

@dochan-consultis
Copy link

I have also same issue with zip files. It is because of mime-types from code of dropzone.js. Allowed are these image/jpeg,image/png,application/zip,application/gzip and from Win10 with chrome when uploading zip is application/x-zip-compressed.

silverwind added a commit to silverwind/gitea that referenced this issue Oct 1, 2020
- Add support for file extensions, matching the `accept` attribute of `<input type="file">`
- Add support for type wildcard mime types, e.g. `image/*`
- Create repository.release.ALLOWED_TYPES setting (default unrestricted)
- Change default for attachment.ALLOWED_TYPES to a list of extensions
- Split out POST /attachments into two endpoints for issue/pr and
  releases to prevent circumvention of allowed types check

Fixes: go-gitea#10172
Fixes: go-gitea#7266
Fixes: go-gitea#12460
Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers
techknowlogick pushed a commit that referenced this issue Oct 5, 2020
)

* Attachments: Add extension support, allow all types for releases

- Add support for file extensions, matching the `accept` attribute of `<input type="file">`
- Add support for type wildcard mime types, e.g. `image/*`
- Create repository.release.ALLOWED_TYPES setting (default unrestricted)
- Change default for attachment.ALLOWED_TYPES to a list of extensions
- Split out POST /attachments into two endpoints for issue/pr and
  releases to prevent circumvention of allowed types check

Fixes: #10172
Fixes: #7266
Fixes: #12460
Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers

* rename function

* extract GET routes out of RepoMustNotBeArchived

Co-authored-by: Lauris BH <lauris@nix.lv>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants