Skip to content

Commit b4927bd

Browse files
committed
Fixed CFURLCopyPath() returning NULL for "//" path
Fix swisspol#297
1 parent 44ffec1 commit b4927bd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

GCDWebServer/Core/GCDWebServerConnection.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ - (void)_readRequestHeaders {
300300
GWS_DCHECK(requestURL);
301301
}
302302
NSString* urlPath = requestURL ? CFBridgingRelease(CFURLCopyPath((CFURLRef)requestURL)) : nil; // Don't use -[NSURL path] which strips the ending slash
303+
if (urlPath == nil) {
304+
urlPath = @"/"; // CFURLCopyPath() returns NULL for a relative URL with path "//" contrary to -[NSURL path] which returns "/"
305+
}
303306
NSString* requestPath = urlPath ? GCDWebServerUnescapeURLString(urlPath) : nil;
304307
NSString* queryString = requestURL ? CFBridgingRelease(CFURLCopyQueryString((CFURLRef)requestURL, NULL)) : nil; // Don't use -[NSURL query] to make sure query is not unescaped;
305308
NSDictionary* requestQuery = queryString ? GCDWebServerParseURLEncodedForm(queryString) : @{};

0 commit comments

Comments
 (0)