mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Prevent NPE on partial match of compare URL and allow short SHA1 compare URLs (#18472)
* Don't panic & allow shorter sha1 - Don't panic when the full regex isn't matched and allow the usage of a shorter sha1 being used. - Resolves #18471 * Update modules/markup/html.go Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
		@@ -548,3 +548,16 @@ func TestFuzz(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestIssue18471(t *testing.T) {
 | 
			
		||||
	data := `http://domain/org/repo/compare/783b039...da951ce`
 | 
			
		||||
 | 
			
		||||
	var res strings.Builder
 | 
			
		||||
	err := PostProcess(&RenderContext{
 | 
			
		||||
		URLPrefix: "https://example.com",
 | 
			
		||||
		Metas:     localMetas,
 | 
			
		||||
	}, strings.NewReader(data), &res)
 | 
			
		||||
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, res.String(), "<a href=\"http://domain/org/repo/compare/783b039...da951ce\" class=\"compare\"><code class=\"nohighlight\">783b039...da951ce</code></a>")
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user