Skip to content
Snippets Groups Projects
Commit 168d0eee authored by George Nachman's avatar George Nachman
Browse files

Validate hostname of ssh URLs and reject anything besides letters, numbers,...

Validate hostname of ssh URLs and reject anything besides letters, numbers, dash, and colon. Colon is allowed for IPV6. Square brackets in IPV6 get stripped by the system.
parent 69c279ff
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1009,8 +1009,16 @@ static iTermController *gSharedInstance;
if ([urlRep port]) {
[tempString appendFormat:@"-p %@ ", [urlRep port]];
}
if ([urlRep host]) {
[tempString appendString:[[urlRep host] stringWithEscapedShellCharactersIncludingNewlines:YES]];
NSString *hostname = [urlRep host];
if (hostname) {
NSCharacterSet *legalCharacters = [NSCharacterSet characterSetWithCharactersInString:@":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-."];
NSCharacterSet *illegalCharacters = [legalCharacters invertedSet];
NSRange range = [hostname rangeOfCharacterFromSet:illegalCharacters];
if (range.location != NSNotFound) {
ELog(@"Hostname %@ contains illegal character at position %@", hostname, @(range.location));
return nil;
}
[tempString appendString:[hostname stringWithEscapedShellCharactersIncludingNewlines:YES]];
}
[tempDict setObject:tempString forKey:KEY_COMMAND_LINE];
[tempDict setObject:@"Yes" forKey:KEY_CUSTOM_COMMAND];
Loading
Loading
@@ -1071,6 +1079,10 @@ static iTermController *gSharedInstance;
DLog(@"Add URL to profile");
// Automatically fill in ssh command if command is exactly equal to $$ or it's a login shell.
aDict = [self profile:aDict modifiedToOpenURL:url forObjectType:objectType];
if (aDict == nil) {
// Bogus hostname detected
return nil;
}
}
if (!bookmarkData) {
DLog(@"Using profile:\n%@", aDict);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment