-
Notifications
You must be signed in to change notification settings - Fork 887
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
Fixes serialization of ProxyServer for mojo. #11028
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should extend unit test ProxySpecificationUtilTest.ProxyUriToProxyServer
with username and password cases and run it. So that we can detect brokerage easily in the future.
It can be done as follow-up so we don't block the release
@darkdh, added a few unit tests. PTAL. Thanks |
} | ||
|
||
std::string result = | ||
scheme_prefix + GetProxyServerAuthString(proxy_server) + proxy_uri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base::StrCat
} | ||
|
||
std::string result = | ||
scheme_prefix + GetProxyServerAuthString(proxy_server) + proxy_pac; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base::StrCat
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace net { | ||
namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests shouldn't be in anonymous namespace. They will work, but we shouldn't encourage this. One of the reasons - you cannot friend
such test fixture.
@@ -72,14 +61,15 @@ std::string ProxyServerToProxyUri(const ProxyServer& proxy_server) { | |||
} | |||
auth_string += '@'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of this can be improved with base::StrAppend
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/ fixes suggested by @goodov (which mostly apply to code I originally wrote, sorry)
Previuosly, serialization of ProxyServer's HostPortPair used its ToString method which we overrode, but now ProxyServerToPacResultElement explicitly constructs the string by getting host() and port() members and calling ConstructHostPortString. We need to override this behavior to insert auth info. Fixes brave/brave-browser#19371 Chromium change: https://source.chromium.org/chromium/chromium/src/+/5dbd4599a981da1fac5dc5211772fe843a06a9b0 commit 5dbd4599a981da1fac5dc5211772fe843a06a9b0 Author: Eric Orth <[email protected]> Date: Fri Sep 24 21:21:24 2021 +0000 Stop dealing with HostPortPair in proxy_string_util.(cc/h) String->ProxyServer now done using ProxyServer::FromSchemeHostAndPort, and ProxyServer->String now done using ProxyServer::GetHost() and ProxyServer::GetPort(). With less ProxyServer-external dealing with HostPortPair, will aide the future-CL transition to not storing HostPortPair for all proxies. Also has the effect that construction-from-string now results in canonicalization of the ProxyServer hostname. Slight impact on tests that were parsing stuff with now-recognized-as-invalid hostnames (especially the v8 tracing tests that were hacking information into wildly invalid hostnames), but don't expect any real-world impact because these are clearly invalid names that shouldn't ever be able to resolve to real servers. Also moved the hostname:port parsing directly into proxy_string_util.cc (from url_util::ParseHostAndPort()) to avoid silliness like stripping IPv6 brackets just for them to be added back for canonicalization. Bug: 1243398
c198485
to
4339800
Compare
Merging as this is blocking the upcoming release. @goodov, please let me know if any additional fixes are needed and I'll do a followup. Thanks. |
Fixes serialization of ProxyServer for mojo.
Fixes serialization of ProxyServer for mojo.
Previuosly, serialization of ProxyServer's HostPortPair used
its ToString method which we overrode, but now
ProxyServerToPacResultElement explicitly constructs the string
by getting host() and port() members and calling
ConstructHostPortString. We need to override this behavior to insert
auth info.
Fixes brave/brave-browser#19371
Chromium change:
https://source.chromium.org/chromium/chromium/src/+/5dbd4599a981da1fac5dc5211772fe843a06a9b0
commit 5dbd4599a981da1fac5dc5211772fe843a06a9b0
Author: Eric Orth [email protected]
Date: Fri Sep 24 21:21:24 2021 +0000
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: