mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 09:31:07 +00:00
fix #31153
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31454 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5c568fd7bb
commit
4cfbd4b8c6
3 changed files with 46 additions and 14 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2010-10-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSURL.m: Fix for bug #31153 ... allow hash in path when
|
||||||
|
initialising.
|
||||||
|
* Source/NSURLProtocol.m: Fix thread related crash with deallocation
|
||||||
|
of placeholder object.
|
||||||
|
|
||||||
2010-09-30 Richard Frith-Macdonald <rfm@gnu.org>
|
2010-09-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSFileHandle.m:
|
* Source/GSFileHandle.m:
|
||||||
|
|
|
@ -670,8 +670,11 @@ static unsigned urlAlign;
|
||||||
{
|
{
|
||||||
/* RFC 2396 'reserved' characters ...
|
/* RFC 2396 'reserved' characters ...
|
||||||
* as modified by RFC2732
|
* as modified by RFC2732
|
||||||
|
* static const char *reserved = ";/?:@&=+$,[]";
|
||||||
*/
|
*/
|
||||||
static const char *reserved = ";/?:@&=+$,[]";
|
/* Same as reserved set but allow the hash character in a path too.
|
||||||
|
*/
|
||||||
|
static const char *filepath = ";/?:@&=+$,[]#";
|
||||||
|
|
||||||
if ([aUrlString isKindOfClass: [NSString class]] == NO)
|
if ([aUrlString isKindOfClass: [NSString class]] == NO)
|
||||||
{
|
{
|
||||||
|
@ -990,7 +993,7 @@ static unsigned urlAlign;
|
||||||
if (buf->fragment == 0 && base != 0)
|
if (buf->fragment == 0 && base != 0)
|
||||||
{
|
{
|
||||||
buf->fragment = base->fragment;
|
buf->fragment = base->fragment;
|
||||||
if (legal(buf->fragment, reserved) == NO)
|
if (legal(buf->fragment, filepath) == NO)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"[%@ %@](%@, %@) "
|
format: @"[%@ %@](%@, %@) "
|
||||||
|
@ -1019,7 +1022,7 @@ static unsigned urlAlign;
|
||||||
if (buf->query == 0 && base != 0)
|
if (buf->query == 0 && base != 0)
|
||||||
{
|
{
|
||||||
buf->query = base->query;
|
buf->query = base->query;
|
||||||
if (legal(buf->query, reserved) == NO)
|
if (legal(buf->query, filepath) == NO)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"[%@ %@](%@, %@) "
|
format: @"[%@ %@](%@, %@) "
|
||||||
|
@ -1048,7 +1051,7 @@ static unsigned urlAlign;
|
||||||
if (buf->parameters == 0 && base != 0)
|
if (buf->parameters == 0 && base != 0)
|
||||||
{
|
{
|
||||||
buf->parameters = base->parameters;
|
buf->parameters = base->parameters;
|
||||||
if (legal(buf->parameters, reserved) == NO)
|
if (legal(buf->parameters, filepath) == NO)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"[%@ %@](%@, %@) "
|
format: @"[%@ %@](%@, %@) "
|
||||||
|
@ -1086,7 +1089,7 @@ static unsigned urlAlign;
|
||||||
{
|
{
|
||||||
buf->hasNoPath = YES;
|
buf->hasNoPath = YES;
|
||||||
}
|
}
|
||||||
if (legal(buf->path, reserved) == NO)
|
if (legal(buf->path, filepath) == NO)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"[%@ %@](%@, %@) "
|
format: @"[%@ %@](%@, %@) "
|
||||||
|
|
|
@ -284,8 +284,34 @@ typedef struct {
|
||||||
static NSMutableArray *registered = nil;
|
static NSMutableArray *registered = nil;
|
||||||
static NSLock *regLock = nil;
|
static NSLock *regLock = nil;
|
||||||
static Class abstractClass = nil;
|
static Class abstractClass = nil;
|
||||||
|
static Class placeholderClass = nil;
|
||||||
static NSURLProtocol *placeholder = nil;
|
static NSURLProtocol *placeholder = nil;
|
||||||
|
|
||||||
|
@interface NSURLProtocolPlaceholder : NSURLProtocol
|
||||||
|
@end
|
||||||
|
@implementation NSURLProtocolPlaceholder
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
if (self == placeholder)
|
||||||
|
{
|
||||||
|
[self retain];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
- (void) release
|
||||||
|
{
|
||||||
|
/* In a multi-threaded environment we could have two threads release the
|
||||||
|
* class at the same time ... causing -dealloc to be called twice at the
|
||||||
|
* same time, so that we can get an exception as we try to decrement the
|
||||||
|
* retain count beyond zero. To avoid this we make the placeholder be a
|
||||||
|
* subclass whose -retain method prevents us even calling -dealoc in any
|
||||||
|
* normal circumstances.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSURLProtocol
|
@implementation NSURLProtocol
|
||||||
|
|
||||||
+ (id) allocWithZone: (NSZone*)z
|
+ (id) allocWithZone: (NSZone*)z
|
||||||
|
@ -313,7 +339,8 @@ static NSURLProtocol *placeholder = nil;
|
||||||
if (registered == nil)
|
if (registered == nil)
|
||||||
{
|
{
|
||||||
abstractClass = [NSURLProtocol class];
|
abstractClass = [NSURLProtocol class];
|
||||||
placeholder = (NSURLProtocol*)NSAllocateObject(abstractClass, 0,
|
placeholderClass = [NSURLProtocolPlaceholder class];
|
||||||
|
placeholder = (NSURLProtocol*)NSAllocateObject(placeholderClass, 0,
|
||||||
NSDefaultMallocZone());
|
NSDefaultMallocZone());
|
||||||
registered = [NSMutableArray new];
|
registered = [NSMutableArray new];
|
||||||
regLock = [NSLock new];
|
regLock = [NSLock new];
|
||||||
|
@ -342,7 +369,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
+(Class) _classToHandleRequest:(NSURLRequest *)request
|
+ (Class) _classToHandleRequest:(NSURLRequest *)request
|
||||||
{
|
{
|
||||||
Class protoClass = nil;
|
Class protoClass = nil;
|
||||||
int count;
|
int count;
|
||||||
|
@ -390,11 +417,6 @@ static NSURLProtocol *placeholder = nil;
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
if (self == placeholder)
|
|
||||||
{
|
|
||||||
[self retain];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this != 0)
|
if (this != 0)
|
||||||
{
|
{
|
||||||
[self stopLoading];
|
[self stopLoading];
|
||||||
|
@ -440,7 +462,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
{
|
{
|
||||||
if ((self = [super init]) != nil)
|
if ((self = [super init]) != nil)
|
||||||
{
|
{
|
||||||
if (isa != abstractClass)
|
if (isa != abstractClass && isa != placeholderClass)
|
||||||
{
|
{
|
||||||
_NSURLProtocolInternal = NSZoneCalloc([self zone],
|
_NSURLProtocolInternal = NSZoneCalloc([self zone],
|
||||||
1, sizeof(Internal));
|
1, sizeof(Internal));
|
||||||
|
@ -453,7 +475,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
cachedResponse: (NSCachedURLResponse *)cachedResponse
|
cachedResponse: (NSCachedURLResponse *)cachedResponse
|
||||||
client: (id <NSURLProtocolClient>)client
|
client: (id <NSURLProtocolClient>)client
|
||||||
{
|
{
|
||||||
if (isa == abstractClass)
|
if (isa == abstractClass || isa == placeholderClass)
|
||||||
{
|
{
|
||||||
unsigned count;
|
unsigned count;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue