Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobile: Fix bugs in the Apple PAC proxy resolver #36409

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions mobile/library/common/network/apple_pac_proxy_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ namespace {

// Creates a CFURLRef from a C++ string URL.
CFURLRef createCFURL(const std::string& url_string) {
auto cf_url_string =
CFStringCreateWithCString(kCFAllocatorDefault, url_string.c_str(), kCFStringEncodingUTF8);
auto cf_url = CFURLCreateWithString(kCFAllocatorDefault, cf_url_string, /*baseURL=*/nullptr);
CFRelease(cf_url_string);
return cf_url;
return CFURLCreateWithBytes(kCFAllocatorDefault,
reinterpret_cast<const UInt8*>(url_string.c_str()),
url_string.length(), kCFStringEncodingUTF8, nullptr);
}

} // namespace
Expand Down Expand Up @@ -80,10 +78,13 @@ ApplePacProxyResolver::createPacUrlResolverSource(CFURLRef cf_proxy_autoconfigur
}

void ApplePacProxyResolver::resolveProxies(
const std::string& target_url, const std::string& proxy_autoconfiguration_file_url,
const std::string& proxy_autoconfiguration_file_url, const std::string& target_url,
ProxySettingsResolvedCallback proxy_resolution_completed) {
CFURLRef cf_target_url = createCFURL(target_url);
CFURLRef cf_proxy_autoconfiguration_file_url = createCFURL(proxy_autoconfiguration_file_url);
if (cf_target_url == nullptr || cf_proxy_autoconfiguration_file_url == nullptr) {
return;
}

std::unique_ptr<ProxySettingsResolvedCallback> completion_callback =
std::make_unique<ProxySettingsResolvedCallback>(std::move(proxy_resolution_completed));
Expand Down
6 changes: 3 additions & 3 deletions mobile/library/common/network/apple_pac_proxy_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class ApplePacProxyResolver {
/**
* Resolves proxy for a given URL using proxy auto configuration file that's hosted at a given
* URL.
* @param target_url A request URL to resolve the proxy for.
* @param proxy_autoconfiguration_file_url A URL at which a proxy configuration file is hosted.
* @param target_url A request URL to resolve the proxy for.
* @param proxy_resolution_completed A function that's called with result proxies as its
* arguments when proxy resolution completes.
*/
void resolveProxies(const std::string& target_url,
const std::string& proxy_autoconfiguration_file_url,
void resolveProxies(const std::string& proxy_autoconfiguration_file_url,
const std::string& target_url,
ProxySettingsResolvedCallback proxy_resolution_completed);

protected:
Expand Down