mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Improve SHA1 link detection (#6526)
This improves the SHA1 link detection to not pick up extraneous non-whitespace characters at the end of the URL. The '.' is a special case handled in code itself because of missing regexp lookahead support. Regex test cases: https://regex101.com/r/xUMlqh/3
This commit is contained in:
		@@ -273,12 +273,12 @@ func TestRegExp_anySHA1Pattern(t *testing.T) {
 | 
			
		||||
	testCases := map[string][]string{
 | 
			
		||||
		"https://github.com/jquery/jquery/blob/a644101ed04d0beacea864ce805e0c4f86ba1cd1/test/unit/event.js#L2703": {
 | 
			
		||||
			"a644101ed04d0beacea864ce805e0c4f86ba1cd1",
 | 
			
		||||
			"test/unit/event.js",
 | 
			
		||||
			"L2703",
 | 
			
		||||
			"/test/unit/event.js",
 | 
			
		||||
			"#L2703",
 | 
			
		||||
		},
 | 
			
		||||
		"https://github.com/jquery/jquery/blob/a644101ed04d0beacea864ce805e0c4f86ba1cd1/test/unit/event.js": {
 | 
			
		||||
			"a644101ed04d0beacea864ce805e0c4f86ba1cd1",
 | 
			
		||||
			"test/unit/event.js",
 | 
			
		||||
			"/test/unit/event.js",
 | 
			
		||||
			"",
 | 
			
		||||
		},
 | 
			
		||||
		"https://github.com/jquery/jquery/commit/0705be475092aede1eddae01319ec931fb9c65fc": {
 | 
			
		||||
@@ -288,13 +288,13 @@ func TestRegExp_anySHA1Pattern(t *testing.T) {
 | 
			
		||||
		},
 | 
			
		||||
		"https://github.com/jquery/jquery/tree/0705be475092aede1eddae01319ec931fb9c65fc/src": {
 | 
			
		||||
			"0705be475092aede1eddae01319ec931fb9c65fc",
 | 
			
		||||
			"src",
 | 
			
		||||
			"/src",
 | 
			
		||||
			"",
 | 
			
		||||
		},
 | 
			
		||||
		"https://try.gogs.io/gogs/gogs/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2": {
 | 
			
		||||
			"d8a994ef243349f321568f9e36d5c3f444b99cae",
 | 
			
		||||
			"",
 | 
			
		||||
			"diff-2",
 | 
			
		||||
			"#diff-2",
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user