zeripath [Sat, 6 Mar 2021 22:53:37 +0000 (22:53 +0000)]
Fix race in LFS ContentStore.Put(...) (#14895) (#14913)
Backport #14895
Continuing on from #14888
The previous implementation has race whereby an incomplete upload or
hash mismatch upload can end up in the ContentStore. This PR moves the
validation into the reader so that if there is a hash error or size
mismatch the reader will return with an error instead of an io.EOF
causing the storage to abort the storage.
zeripath [Sun, 28 Feb 2021 13:19:51 +0000 (13:19 +0000)]
Fix a couple of CommentAsPatch issues. (#14804) (#14820)
Backport #14804
* CutDiffAroundLine makes the incorrect assumption that `---` and `+++` always represent part of the header of a diff.
This PR adds a flag to its parsing to prevent this problem and adds a streaming parsing technique to CutDiffAroundLine using an io.pipe instead of just sending data to an unbounded buffer.
Fix #14711
* Handle unquoted comment patch files
When making comment patches unfortunately the patch does not always quote the filename
This makes the diff --git header ambiguous again.
This PR finally adds handling for ambiguity in to parse patch
Fix #14812
* Add in testing for no error
There is no way currently for CutDiffAroundLine in this test to cause an
error however, it should still be tested.
zeripath [Sun, 14 Feb 2021 23:30:07 +0000 (23:30 +0000)]
Fix broken spans in diffs (#14678) (#14683)
Backport #14678
Gitea runs diff on highlighted code fragment for each line in order to
provide code highlight diffs. Unfortunately this diff algorithm is not
aware that span tags and entities are atomic and cannot be split.
The current fixup code makes some attempt to fix these broken tags
however, it cannot handle situations where a tag is split over multiple
blocks.
This PR provides a more algorithmic fixup mechanism whereby spans and
entities are completely coalesced into their respective blocks.
This may result in a incompletely reduced diff but - it will definitely
prevent the broken entities and spans that are currently possible.
As a result of this fixup several inconsistencies were discovered in our
testcases and these were also fixed.
Fix #14231
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
zeripath [Sun, 14 Feb 2021 22:44:26 +0000 (22:44 +0000)]
HasPreviousCommit causes recursive load of commits unnecessarily (#14598) (#14649)
This PR improves HasPreviousCommit to prevent the automatic and recursive loading
of previous commits using git merge-base --is-ancestor and git rev-list
Fix #13684
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Anton Khimich [Thu, 4 Feb 2021 20:28:48 +0000 (15:28 -0500)]
Fix GPG key deletion during account deletion (#14561) (#14569)
Per #14531, deleting a user account will delete the user's GPG keys
from the `gpg_key` table but not from `gpg_key_import`, which causes
an error when creating an account with the same email and attempting
to re-add the same key. This commit deletes all entries from
`gpg_key_import` that match any GPG key IDs belonging to the user.
Co-authored-by: Anton Khimich <anton.khimicha@mail.utoronto.ca>
6543 [Sat, 30 Jan 2021 19:47:11 +0000 (20:47 +0100)]
Set the name Mapper in migrations (#14526) (#14529)
Migrations currently uses the default Xorm mapper which is
not the same as the mapper Gitea actually uses.
This means that there is a difference between the struct
parsing and mapping to database tables in migrations as
compared to normal Sync2.
This was the cause for the catastrophic problem in v168 -
untagged fields are not mapped in the same way in migrations
as compared to outside of migrations.
This is also likely the cause of some weird subtle failures
in other migrations as any untagged field may not be being
mapped exactly the same way.
This PR suggests that we ensure that the mapper is set at
the start of the migrations code - but also enforces a strict
clean mapper between each migration.
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
6543 [Wed, 20 Jan 2021 18:47:30 +0000 (19:47 +0100)]
Prevent panic on fuzzer provided string (#14405) (#14409)
* Prevent panic on fuzzer provided string
The fuzzer has found that providing a <body> tag with an attribute to
PostProcess causes a panic. This PR removes any rendered html or body
tags from the output.
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Placate lint
* placate lint again
Signed-off-by: Andrew Thornton <art27@cantab.net>
* minor cleanup
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
The design is very flexible, but not implemented correctly.
This commit fixes several issues:
* Costom storage type stated in https://docs.gitea.io/en-us/config-cheat-sheet/#storage-storage
not working
* [storage.attachments], [storage.minio] section not respected
mrsdizzie [Thu, 17 Dec 2020 16:39:12 +0000 (11:39 -0500)]
Don't use simpleMDE editor on mobile devices for 1.13 (#14029)
* Don't use simpleMDE editor on mobile devices
simpleMDE doesn't work properly on mobile devices -- We've replaced it with the slightly more working easyMDE in 1.14 but since that change can't be backported to 1.13 we will just disable the editor on mobile here.
* make isMobile function per code review -- disable simpleMDE for code review and replies
zeripath [Mon, 14 Dec 2020 20:35:40 +0000 (20:35 +0000)]
Trim the branch prefix from action.GetBranch (#13981) (#13986)
Backport #13981
#13882 has revealed that the refname of an action is actually only a
refname pattern and necessarily a branch. For examplem pushing to
refs/heads/master will result in action with refname refs/heads/master
but pushing to master will result in a refname master.
The simplest solution to providing a fix here is to trim the prefix
therefore this PR proposes this.
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
zeripath [Sun, 13 Dec 2020 00:01:44 +0000 (00:01 +0000)]
Whenever the password is updated ensure that the hash algorithm is too (#13966) (#13967)
Backport #13966
`user.HashPassword` may potentially - and in fact now likely does - change
the `passwd_hash_algo` therefore whenever the `passwd` is updated, this
also needs to be updated.
silverwind [Tue, 1 Dec 2020 01:55:38 +0000 (02:55 +0100)]
Set RUN_MODE prod by default (#13765) (#13767)
* Set RUN_MODE prod by default (#13765)
I think it's a bad default to have "dev" as the default run mode which
enables debugging and now also disables HTTP caching. It's better to
just default to a value suitable for general deployments.
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* flip default in checkRunMode
silverwind [Mon, 30 Nov 2020 19:51:48 +0000 (20:51 +0100)]
Fix bogus http requests on diffs (#13760) (#13761)
The .blob-excerpt elements don't have these data attributes in some
cases resulting in bogus http request when expanding a diff and clicking
into the expanded area. This prevents those.
zeripath [Sat, 28 Nov 2020 21:59:32 +0000 (21:59 +0000)]
Push HEAD instead of master when initialising repositories (#13719) (#13740)
* Push HEAD instead of master when initialising repositories
It is possible on modern gits to change the initial branch to something other than
master. This breaks initialising repositories because we assume that the initial
branch is going to be master unless specifically changed.
This PR simply bypasses this issue by pushing the HEAD rather than the master branch.
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update modules/repository/init.go