mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Handle ssh key import better (#224)
* Handle user ssh key input better ssh_key: when user submitted keys had a newline at the end, strings.Split would have created a slice with an empty last element, and the key type check would be incorrect. Perhaps a better way is to look for 'ssh-rsa' or 'ssh-dsa' at the beginning of the string, but this is simple. * ssh_key: correct indentation
This commit is contained in:
		@@ -105,6 +105,8 @@ func extractTypeFromBase64Key(key string) (string, error) {
 | 
				
			|||||||
func parseKeyString(content string) (string, error) {
 | 
					func parseKeyString(content string) (string, error) {
 | 
				
			||||||
	// Transform all legal line endings to a single "\n".
 | 
						// Transform all legal line endings to a single "\n".
 | 
				
			||||||
	content = strings.NewReplacer("\r\n", "\n", "\r", "\n").Replace(content)
 | 
						content = strings.NewReplacer("\r\n", "\n", "\r", "\n").Replace(content)
 | 
				
			||||||
 | 
						// remove trailing newline (and beginning spaces too)
 | 
				
			||||||
 | 
						content = strings.TrimSpace(content)
 | 
				
			||||||
	lines := strings.Split(content, "\n")
 | 
						lines := strings.Split(content, "\n")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var keyType, keyContent, keyComment string
 | 
						var keyType, keyContent, keyComment string
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user