gitea/modules
Gary Kim 7eed11e5e9 Check commit message hashes before making links (#7713)
* Check commit message hashes before making links

Previously, when formatting commit messages, anything
that looked like SHA1 hashes was turned into a link
using regex. This meant that certain phrases or numbers
such as `777777` or `deadbeef` could be recognized as a commit
even if the repository has no commit with those hashes.

This change will make it so that anything that looks
like a SHA1 hash using regex will then also be checked
to ensure that there is a commit in the repository
with that hash before making a link.

Signed-off-by: Gary Kim <gary@garykim.dev>

* Use gogit to check if commit exists

This commit modifies the commit hash check
in the render for commit messages to use
gogit for better performance.

Signed-off-by: Gary Kim <gary@garykim.dev>

* Make code cleaner

Signed-off-by: Gary Kim <gary@garykim.dev>

* Use rev-parse to check if commit exists

Signed-off-by: Gary Kim <gary@garykim.dev>

* Add and modify tests for checking hashes in html link rendering

Signed-off-by: Gary Kim <gary@garykim.dev>

* Return error in sha1CurrentPatternProcessor

Co-Authored-By: mrsdizzie <info@mrsdizzie.com>

* Import Gitea log module

Signed-off-by: Gary Kim <gary@garykim.dev>

* Revert "Return error in sha1CurrentPatternProcessor"

This reverts commit 28f561cac4.

Signed-off-by: Gary Kim <gary@garykim.dev>

* Add debug logging to sha1CurrentPatternProcessor

This will log errors by the git command run in
sha1CurrentPatternProcessor if the error is one
that was unexpected.

Signed-off-by: Gary Kim <gary@garykim.dev>
2019-08-14 16:04:55 +08:00
..
auth Make captcha and password optional for external accounts (#6606) 2019-07-06 15:48:02 -04:00
avatar
base
cache
context Removed unnecessary conversions (#7557) 2019-07-23 19:50:39 +01:00
cron Move status table to cron package (#7370) 2019-07-15 20:13:03 -04:00
generate
git Do not fetch all refs (#7797) 2019-08-13 11:30:44 +03:00
gzip
highlight Add a lot of extension to language mappings for syntax highlights (#7741) 2019-08-05 23:48:31 +08:00
httplib
indexer Remove camel case tokenization from repo indexer (#7733) 2019-08-06 07:38:16 +03:00
lfs Removed unnecessary conversions (#7557) 2019-07-23 19:50:39 +01:00
log Removed unnecessary conversions (#7557) 2019-07-23 19:50:39 +01:00
mailer
markup Check commit message hashes before making links (#7713) 2019-08-14 16:04:55 +08:00
metrics
migrations Import topics during migration (#7851) 2019-08-14 14:16:12 +08:00
minwinsvc
notification
options remove unnecessary fmt on generate bindata (#7706) 2019-08-01 13:34:46 -04:00
pprof
private
process
public remove unnecessary fmt on generate bindata (#7706) 2019-08-01 13:34:46 -04:00
pull Fix duplicate call of webhook (#7821) 2019-08-11 23:31:18 +03:00
recaptcha
repofiles Fix duplicate call of webhook (#7821) 2019-08-11 23:31:18 +03:00
search
secret
session
setting Remove settting dependency on modules/session (#7237) 2019-07-17 09:04:37 +08:00
ssh switch to use gliderlabs/ssh for builtin server (#7250) 2019-07-06 21:28:09 -04:00
structs Be more strict with git arguments (#7715) 2019-08-05 21:39:39 +01:00
sync
templates remove unnecessary fmt on generate bindata (#7706) 2019-08-01 13:34:46 -04:00
test
upload Refactor filetype is not allowed errors (#7309) 2019-07-06 22:25:05 -04:00
user
util
validation Fix lax comparison in validation tests (#7815) 2019-08-12 10:17:25 +08:00