Make URL parsing a bit stricter like MacOS-X

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24375 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-01-17 09:40:24 +00:00
parent a1fc7d99b9
commit fb1fbe5517
2 changed files with 25 additions and 0 deletions

View file

@ -2,6 +2,7 @@
* Source/NSURLHandle.m: ([resourceData]) make sure value returned
is autoreleased.
* Source/NSURL.m: Parse string a bit more strictly according to RFC
2007-01-16 Nicola Pero <nicola.pero@meta-innovation.com>

View file

@ -627,6 +627,10 @@ static unsigned urlAlign;
- (id) initWithString: (NSString*)aUrlString
relativeToURL: (NSURL*)aBaseUrl
{
/* RFC 2396 'reserved' characters ...
*/
static const char *reserved = ";/?:@&=+$,";
if (aUrlString == nil)
{
[NSException raise: NSInvalidArgumentException
@ -879,6 +883,11 @@ static unsigned urlAlign;
if (buf->fragment == 0 && base != 0)
{
buf->fragment = base->fragment;
if (legal(buf->fragment, reserved) == NO)
{
[NSException raise: NSGenericException format:
@"illegal character in fragment part"];
}
}
}
@ -899,6 +908,11 @@ static unsigned urlAlign;
if (buf->query == 0 && base != 0)
{
buf->query = base->query;
if (legal(buf->query, reserved) == NO)
{
[NSException raise: NSGenericException format:
@"illegal character in query part"];
}
}
}
@ -919,6 +933,11 @@ static unsigned urlAlign;
if (buf->parameters == 0 && base != 0)
{
buf->parameters = base->parameters;
if (legal(buf->parameters, reserved) == NO)
{
[NSException raise: NSGenericException format:
@"illegal character in parameters part"];
}
}
}
@ -944,6 +963,11 @@ static unsigned urlAlign;
* Store the path.
*/
buf->path = start;
if (legal(buf->path, reserved) == NO)
{
[NSException raise: NSGenericException format:
@"illegal character in path part"];
}
}
NS_HANDLER
{