(fix) avoid crashing due to bogus URLs (GNUstep braindamage)

pull/210/head
Ludovic Marcotte 2016-05-27 15:29:33 -04:00
parent f4d83bfa19
commit 1ba8ba9e58
1 changed files with 14 additions and 4 deletions

View File

@ -20,6 +20,7 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSException.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSValue.h>
@ -436,12 +437,21 @@
for (count = 0; count < max; count++)
{
stringAttach = [[elements objectAtIndex: count] flattenedValuesForKey: @""];
url = [NSURL URLWithString: stringAttach];
if (![url scheme] && [stringAttach length] > 0)
url = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@", stringAttach]];
NS_DURING
{
url = [NSURL URLWithString: stringAttach];
[attachUrls addObject: [url absoluteString]];
if (![url scheme] && [stringAttach length] > 0)
url = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@", stringAttach]];
[attachUrls addObject: [url absoluteString]];
}
NS_HANDLER
{
// Invalid URL, skipping.
}
NS_ENDHANDLER
}
return attachUrls;