mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fix panic in BasicAuthDecode (#14046)
* Fix panic in BasicAuthDecode If the string does not contain ":" that function would run into an `index out of range [1] with length 1` error. prevent that. * Update BasicAuthDecode() Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
		@@ -43,6 +43,12 @@ func TestBasicAuthDecode(t *testing.T) {
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
	assert.Equal(t, "foo", user)
 | 
			
		||||
	assert.Equal(t, "bar", pass)
 | 
			
		||||
 | 
			
		||||
	_, _, err = BasicAuthDecode("aW52YWxpZA==")
 | 
			
		||||
	assert.Error(t, err)
 | 
			
		||||
 | 
			
		||||
	_, _, err = BasicAuthDecode("invalid")
 | 
			
		||||
	assert.Error(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestBasicAuthEncode(t *testing.T) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user