Skip to content

Commit 943eb60

Browse files
committed
Add support and tests for URLComponents.percentEncodedQueryItems
rdar://59439703 (URLComponents.percentEncodedQueryItems missing on linux)
1 parent c971e6f commit 943eb60

File tree

5 files changed

+370
-86
lines changed

5 files changed

+370
-86
lines changed

CoreFoundation/URL.subproj/CFURLComponents.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,9 @@ static Boolean _CFURLComponentsSetQueryItemsInternal(CFURLComponentsRef componen
14091409
if ( name && name != kCFNull ) {
14101410
if ( addPercentEncoding ) {
14111411
CFStringRef stringWithPercentEncoding = _CFStringCreateByAddingPercentEncodingWithAllowedCharacters(kCFAllocatorSystemDefault, name, queryNameValueAllowed);
1412+
if ( !stringWithPercentEncoding ) {
1413+
stringWithPercentEncoding = (CFStringRef)CFRetain(CFSTR(""));
1414+
}
14121415
CFStringAppendStringToAppendBuffer(&buf, stringWithPercentEncoding);
14131416
CFRelease(stringWithPercentEncoding);
14141417
}
@@ -1426,6 +1429,9 @@ static Boolean _CFURLComponentsSetQueryItemsInternal(CFURLComponentsRef componen
14261429
CFStringAppendCharactersToAppendBuffer(&buf, chars, 1);
14271430
if ( addPercentEncoding ) {
14281431
CFStringRef stringWithPercentEncoding = _CFStringCreateByAddingPercentEncodingWithAllowedCharacters(kCFAllocatorSystemDefault, value, queryNameValueAllowed);
1432+
if ( !stringWithPercentEncoding ) {
1433+
stringWithPercentEncoding = (CFStringRef)CFRetain(CFSTR(""));
1434+
}
14291435
CFStringAppendStringToAppendBuffer(&buf, stringWithPercentEncoding);
14301436
CFRelease(stringWithPercentEncoding);
14311437
}
@@ -1461,6 +1467,8 @@ static Boolean _CFURLComponentsSetQueryItemsInternal(CFURLComponentsRef componen
14611467
return ( result );
14621468
}
14631469

1470+
1471+
14641472
CF_EXPORT void _CFURLComponentsSetQueryItems(CFURLComponentsRef components, CFArrayRef names, CFArrayRef values ) {
14651473
(void)_CFURLComponentsSetQueryItemsInternal(components, names, values, true); // _CFURLComponentsSetQueryItemsInternal cannot fail if addPercentEncoding is true
14661474
}

0 commit comments

Comments
 (0)