mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Exactly match the percent escapes used by OSX
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31501 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bdaf339b92
commit
69322fcaca
2 changed files with 74 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2010-10-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSURL.m: Exactly match the percent escaping used by OSX.
|
||||||
|
|
||||||
2010-10-08 Eric Wasylishen <ewasylishen@gmail.com>
|
2010-10-08 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/GSAvahiRunLoopIntegration.m: Fix some bugs:
|
* Source/GSAvahiRunLoopIntegration.m: Fix some bugs:
|
||||||
|
@ -216,7 +220,7 @@
|
||||||
Change sel_getUid to call sel_registerName, in line with OS X
|
Change sel_getUid to call sel_registerName, in line with OS X
|
||||||
behaviour since 10.0
|
behaviour since 10.0
|
||||||
|
|
||||||
2010-09-02 9avid Chisnall <theraven@gna.org>
|
2010-09-02 David Chisnall <theraven@gna.org>
|
||||||
|
|
||||||
* Source/NSBundle.m
|
* Source/NSBundle.m
|
||||||
* Source/NSMethodSignature.m
|
* Source/NSMethodSignature.m
|
||||||
|
|
|
@ -40,6 +40,7 @@ function may be incorrect
|
||||||
#define EXPOSE_NSURL_IVARS 1
|
#define EXPOSE_NSURL_IVARS 1
|
||||||
#import "Foundation/NSArray.h"
|
#import "Foundation/NSArray.h"
|
||||||
#import "Foundation/NSCoder.h"
|
#import "Foundation/NSCoder.h"
|
||||||
|
#import "Foundation/NSData.h"
|
||||||
#import "Foundation/NSDictionary.h"
|
#import "Foundation/NSDictionary.h"
|
||||||
#import "Foundation/NSException.h"
|
#import "Foundation/NSException.h"
|
||||||
#import "Foundation/NSFileManager.h"
|
#import "Foundation/NSFileManager.h"
|
||||||
|
@ -54,6 +55,73 @@ function may be incorrect
|
||||||
NSString * const NSURLErrorDomain = @"NSURLErrorDomain";
|
NSString * const NSURLErrorDomain = @"NSURLErrorDomain";
|
||||||
NSString * const NSErrorFailingURLStringKey = @"NSErrorFailingURLStringKey";
|
NSString * const NSErrorFailingURLStringKey = @"NSErrorFailingURLStringKey";
|
||||||
|
|
||||||
|
@interface NSString (NSURLPrivate)
|
||||||
|
- (NSString*) _stringByAddingPercentEscapes;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSString (NSURLPrivate)
|
||||||
|
/* Like the normal percent escape method, but with additional characters
|
||||||
|
* escaped.
|
||||||
|
*/
|
||||||
|
- (NSString*) _stringByAddingPercentEscapes
|
||||||
|
{
|
||||||
|
NSData *data = [self dataUsingEncoding: NSUTF8StringEncoding];
|
||||||
|
NSString *s = nil;
|
||||||
|
|
||||||
|
if (data != nil)
|
||||||
|
{
|
||||||
|
unsigned char *src = (unsigned char*)[data bytes];
|
||||||
|
unsigned int slen = [data length];
|
||||||
|
unsigned char *dst;
|
||||||
|
unsigned int spos = 0;
|
||||||
|
unsigned int dpos = 0;
|
||||||
|
|
||||||
|
dst = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), slen * 3);
|
||||||
|
while (spos < slen)
|
||||||
|
{
|
||||||
|
unsigned char c = src[spos++];
|
||||||
|
unsigned int hi;
|
||||||
|
unsigned int lo;
|
||||||
|
|
||||||
|
if (c <= 32
|
||||||
|
|| c > 126
|
||||||
|
|| c == 34
|
||||||
|
|| c == 35
|
||||||
|
|| c == 37
|
||||||
|
|| c == 59
|
||||||
|
|| c == 60
|
||||||
|
|| c == 62
|
||||||
|
|| c == 63
|
||||||
|
|| c == 91
|
||||||
|
|| c == 92
|
||||||
|
|| c == 93
|
||||||
|
|| c == 94
|
||||||
|
|| c == 96
|
||||||
|
|| c == 123
|
||||||
|
|| c == 124
|
||||||
|
|| c == 125)
|
||||||
|
{
|
||||||
|
dst[dpos++] = '%';
|
||||||
|
hi = (c & 0xf0) >> 4;
|
||||||
|
dst[dpos++] = (hi > 9) ? 'A' + hi - 10 : '0' + hi;
|
||||||
|
lo = (c & 0x0f);
|
||||||
|
dst[dpos++] = (lo > 9) ? 'A' + lo - 10 : '0' + lo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dst[dpos++] = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s = [[NSString alloc] initWithBytes: dst
|
||||||
|
length: dpos
|
||||||
|
encoding: NSASCIIStringEncoding];
|
||||||
|
NSZoneFree(NSDefaultMallocZone(), dst);
|
||||||
|
IF_NO_GC([s autorelease];)
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure describing a URL.
|
* Structure describing a URL.
|
||||||
* All the char* fields may be NULL pointers, except path, which
|
* All the char* fields may be NULL pointers, except path, which
|
||||||
|
@ -542,8 +610,7 @@ static unsigned urlAlign;
|
||||||
{
|
{
|
||||||
NSString *aUrlString = [NSString alloc];
|
NSString *aUrlString = [NSString alloc];
|
||||||
|
|
||||||
aPath
|
aPath = [aPath _stringByAddingPercentEscapes];
|
||||||
= [aPath stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
|
|
||||||
if ([aHost length] > 0)
|
if ([aHost length] > 0)
|
||||||
{
|
{
|
||||||
NSRange r = [aHost rangeOfString: @"@"];
|
NSRange r = [aHost rangeOfString: @"@"];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue