47 Commits (ac701637b42d2d6bb5fe9b258f3f54959b6a505e)

Author SHA1 Message Date
Farid AYOUJIL f72ce26326
Add Content-Length header to HEAD requests (#14542)
* Add Content-Length header to HEAD requests

This change adds the header Content-Length to HEAD HTTP requests.

The previous behaviour was blocking some Windows executables (i.e
bitsadmin.exe) from downloading files hosted in Gitea.

This along with PR #14541, makes the web server compliant with HTTP RFC 2616 which states
"The methods GET and HEAD MUST be supported by all general-purpose servers"
and
"The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response."

This should also respond to issues #8030 and #14532.

* This change adds the header Content-Length to HEAD HTTP requests

Pass the Size of the content as a parameter to ServeData() instead of
calculating it using ioutil.ReadAll(reader) --> this call is dangerous
and can result in a denial of service.

* Add Content-Length header to HEAD requests

Quick fix for imported dependency not used.

* Check if size is positiv int ...

Co-authored-by: zeripath <art27@cantab.net>
3 years ago
Jonathan Tran 81467e6f35
Display SVG files as images instead of text (#14101)
* Change to display SVG files as images

* Remove unsafe styles from SVG CSP

* Add integration test to test SVG headers

* Add config setting to disable SVG rendering

* Add test for img tag when loading SVG image

* Remove the Raw view button for svg files since we don't fully support this

* Fix copyright year

* Rename and move config setting

* Add setting to cheat sheet in docs

* Fix so that comment matches cheat sheet

* Add allowing styles in CSP based on pull request feedback

* Re-enable raw button since we show SVG styles now

* Change so that SVG files are editable

* Add UI to toggle between source and rendered image for SVGs

* Change to show blame button for SVG images

* Fix to update ctx data

* Add test for DetectContentType when file is longer than sniffLen

Co-authored-by: Jonathan Tran <jon@allspice.io>
Co-authored-by: Kyle D <kdumontnu@gmail.com>
4 years ago
kolaente 64133126cd
Update golangci-lint to version 1.31.0 (#13102)
This PR updates golangci-lint to the latest version 1.31.0.

The upgrade introduced a new check for which I've fixed or disabled most cases.

Signed-off-by: kolaente <k@knt.li>
4 years ago
Lunny Xiao 62e6c9bc6c
Add a storage layer for attachments (#11387)
* Add a storage layer for attachments

* Fix some bug

* fix test

* Fix copyright head and lint

* Fix bug

* Add setting for minio and flags for migrate-storage

* Add documents

* fix lint

* Add test for minio store type on attachments

* fix test

* fix test

* Apply suggestions from code review

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Add warning when storage migrated successfully

* Fix drone

* fix test

* rebase

* Fix test

* display the error on console

* Move minio test to amd64 since minio docker don't support arm64

* refactor the codes

* add trace

* Fix test

* remove log on xorm

* Fi download bug

* Add a storage layer for attachments

* Add setting for minio and flags for migrate-storage

* fix lint

* Add test for minio store type on attachments

* Apply suggestions from code review

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Fix drone

* fix test

* Fix test

* display the error on console

* Move minio test to amd64 since minio docker don't support arm64

* refactor the codes

* add trace

* Fix test

* Add URL function to serve attachments directly from S3/Minio

* Add ability to enable/disable redirection in attachment configuration

* Fix typo

* Add a storage layer for attachments

* Add setting for minio and flags for migrate-storage

* fix lint

* Add test for minio store type on attachments

* Apply suggestions from code review

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Fix drone

* fix test

* Fix test

* display the error on console

* Move minio test to amd64 since minio docker don't support arm64

* don't change unrelated files

* Fix lint

* Fix build

* update go.mod and go.sum

* Use github.com/minio/minio-go/v6

* Remove unused function

* Upgrade minio to v7 and some other improvements

* fix lint

* Fix go mod

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Tyler <tystuyfzand@gmail.com>
4 years ago
zeripath 2ef318e6f1
Add Access-Control-Expose-Headers (#12446)
Fix #12424

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
4 years ago
Lunny Xiao 737ea6d83c
Fix download file wrong content-type (#9825)
* Fix download file wrong content-type

* change the error text to be more precise

* fix test
5 years ago
zeripath e1505d6250
Add missed close in ServeBlobLFS (#8527) 5 years ago
kolaente f9ec2f89f2 Add golangci (#6418) 5 years ago
Lunny Xiao d578b71d61
move code.gitea.io/git to code.gitea.io/gitea/modules/git (#6364)
* move code.gitea.io/git to code.gitea.io/gitea/modules/git

* fix imports

* fix fmt

* fix misspell

* remove wrong tests data

* fix unit tests

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* enable Debug to trace the failure tests

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* comment commit count tests since git clone depth is 50

* fix tests

* update from code.gitea.io/git

* revert change to makefile
5 years ago
zeripath 2a03e96bce
Allow markdown files to read from the LFS (#5787)
This PR makes it possible for the markdown renderer to render images and media straight from the LFS.

Fix #5746

Signed-off-by: Andrew Thornton [art27@cantab.net](mailto:art27@cantab.net)
5 years ago
Peter Hoffmann e08c7e521b Add raw blob endpoint to get objects by SHA ID (#5334)
* Add raw blob endpoint

This should make it possible to download raw blobs directly from
/:repo/:username/raw/blob/:sha1 URLs.

* fix: Make it work

* As an SHA-ID is no path getRefNameFromPath can't be used to verify
file specifying parameter
* added relevant change in go-gitea/git #132

Signed-off-by: Berengar W. Lehr <Berengar.Lehr@kompetenztest.de>

* Update Gopkg.lock

Can't update all vendors due to errors

Signed-off-by: Berengar W. Lehr <Berengar.Lehr@kompetenztest.de>

* style: Add Gitea copyright header

* feat: Added integration test for /repo/u/r/raw/blob

* fix: correct year in copyright header
6 years ago
Morgan Bazalgette 65861900cd Handle refactor (#3339)
* Replace all ctx.Handle with ctx.ServerError or ctx.NotFound

* Change Handle(403) to NotFound, avoid using macaron's NotFound
7 years ago
Duncan Ogilvie 551f3cbe42 Memory usage improvements (#3013)
* govendor update code.gitea.io/git

Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>

* Greatly improve memory usage

Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>
7 years ago
silverwind 935caa7f95 Download files to their original filename (#1676) 7 years ago
Lauris BH bb14c97d40 Fix empty file download (#1506) 7 years ago
Andrey Nering d647d02c2f Fix Chrome not liking commas 8 years ago
Andrey Nering 638dd24cec Fix HTTP headers for issue attachment download
- Download filename was wrong for files other than images. Example: It was `download` instead of `file.pdf`
- PDF was downloading instead of showing on browser
8 years ago
Lunny Xiao 3917ed45de golint fixed for routers (#208) 8 years ago
Sandro Santilli 4247304f5a Update import paths from github.com/go-gitea to code.gitea.io (#135)
- Update import paths from github.com/go-gitea to code.gitea.io
- Fix import path for travis

See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
8 years ago
Sandro Santilli 6e4252dad4 Replace gogits/git-module dependency with go-gitea/git (#94)
* Replace gogits/git-module dependency with go-gitea/git

Fixes #92

* Remove git alias for git module import (not needed)
8 years ago
Rémy Boulanouar 2d68bd1ef9 Change import reference to match gitea instead of gogs (#37) 8 years ago
Unknwon 780cc2d110 router/repo: code refactoring 8 years ago
Unknwon f8a48ffaad Web editor: improve code quality 8 years ago
Unknwon ab9c5fb5e7 #2593 allow render raw content
Use URL query parameter render=1 to render content in raw mode.
8 years ago
Tamás Molnár 39356f4238 Set utf-8 charset for text files when serving raw content (#2898) 8 years ago
Unknwon dd36c431ec #2842 add quotes to attachment file name 8 years ago
Unknwon 514382e2eb Rename module: middleware -> context 8 years ago
Unknwon 93f03707a7 #2283 set text/plain for non-binary files in raw mode 9 years ago
Unknwon 19423957b1 rename import path 9 years ago
Unknwon 9a2e43bff2 move out git module and #1573 send push hook 9 years ago
无闻 8be0bb177b Merge pull request #1485 from donbowman/mime-type
43bfee0d48 reverted my change
9 years ago
Don Bowman 4137426c88 43bfee0d48 reverted my change
423b1c69be, which in turn
causes all content to be served as text/plain. Let go decide
what the mime type is (e.g. text/html instead of text/plain).
9 years ago
Unknwon e67659bf8e fix serve attachment content type 9 years ago
Vladimir Vissoultchev 2cc050e21e Fix UTF-8 in upper-case, use ansi charset for all non UTF-8 encodings 9 years ago
Vladimir Vissoultchev 43bfee0d48 Raw text file view returns correct charset in content-type header if not utf-8 9 years ago
Don Bowman 423b1c69be don't set mime type to text/plain. This will break serving e.g. raw images,
html, etc

According to http://golang.org/pkg/net/http/#DetectContentType
"If the Header does not contain a Content-Type line, Write adds
a Content-Type set to the result of passing the initial 512 bytes
of written data to DetectContentType."
9 years ago
Unknwon 32152d2363 routers/repo: set raw page content type to 'text/plain' #828 10 years ago
Unknwon a0f9197b45 GetFile api 10 years ago
Unknwon 23eec25274 Fix #605, fix #255, fix #101 10 years ago
Unknwon 5c4bc3c848 Huge updates!!!!! Be careful to merge!!!! 10 years ago
Unknwon 8dd07c0ddd New UI merge in progress 10 years ago
Jan Oliver Oelerich 6fe43eb8d4 Fixed directory permissions for the zip download router
If the archives/ directory is created with 0655, it results in a permission error.
10 years ago
slene 4ee6bc4fca fix for new git api 10 years ago
Unknown 688ec6ecbd Fixed #209 10 years ago
Unknown 04890904f9 fix #195 10 years ago
Unknown 956f011dd3 Fix #186 10 years ago
slene 4fafc76052 zip archive download 10 years ago