summaryrefslogtreecommitdiff
path: root/ucbhelper/source/client/proxydecider.cxx
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-08-18 15:09:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-08-18 18:33:27 +0200
commitf88af95552f9b46e1714964d84c447327b50ed40 (patch)
tree74e49defd9b8491354be0fa46e3854373b240239 /ucbhelper/source/client/proxydecider.cxx
parent9b30b4b1678e8be15ba51d236bd9a3e693d8d3d6 (diff)
ucbhelper,ucb,desktop: InternetProxyServer is problematic
It turns out that every single client of InternetProxyDecider simply concatenates the 2 members of InternetProxyServer into a single string and passes it on to curl_easy_setopt(CURLOPT_PROXY), which will happily take a URL including scheme and everything. It turns out that the awful GetUnixSystemProxy() tries to cut off the scheme in a terrible way, but GetPACProxy() does no such thing and WINHTTP_PROXY_INFO::lpszProxy may or may not contain scheme in its entries; fix this to only separate the port and leave the rest alone. So why do we need a InternetProxyServer struct? Because officecfg has separate entries that correspond to its members, and so InternetProxyDecider gets separate events on its listener interface when any of them changes, which is easiest to handle if it stores these separately. So just return a concatenated URL with or without scheme in getProxy(). Change-Id: I43c696471c8bec90667b5930fa00975adb432fe1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155840 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper/source/client/proxydecider.cxx')
-rw-r--r--ucbhelper/source/client/proxydecider.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx
index a46cfa268971..a2abf5a80cdd 100644
--- a/ucbhelper/source/client/proxydecider.cxx
+++ b/ucbhelper/source/client/proxydecider.cxx
@@ -585,8 +585,9 @@ InternetProxyServer GetUnixSystemProxy(const OUString & rProtocol)
OUString tmp = OUString::createFromAscii(pEnvProxy);
if (tmp.getLength() < (rProtocol.getLength() + 3))
return aProxy;
- tmp = tmp.copy(rProtocol.getLength() + 3);
- sal_Int32 x = tmp.indexOf(':');
+ sal_Int32 x = tmp.indexOf("://");
+ sal_Int32 at = tmp.indexOf('@', x == -1 ? 0 : x + 3);
+ x = tmp.indexOf(':', at == -1 ? x == -1 ? 0 : x + 3 : at + 1);
if (x == -1)
return aProxy;
int nPort = o3tl::toInt32(tmp.subView(x + 1));
@@ -937,13 +938,19 @@ bool InternetProxyDecider::shouldUseProxy( const OUString & rProtocol,
return !rData.aName.isEmpty();
}
-
-InternetProxyServer InternetProxyDecider::getProxy(
+OUString InternetProxyDecider::getProxy(
const OUString & rProtocol,
const OUString & rHost,
sal_Int32 nPort ) const
{
- return m_xImpl->getProxy( rProtocol, rHost, nPort );
+ InternetProxyServer ret(m_xImpl->getProxy(rProtocol, rHost, nPort));
+
+ if (ret.aName.isEmpty() || ret.nPort == -1)
+ {
+ return ret.aName;
+ }
+
+ return ret.aName + ":" + OUString::number(ret.nPort);
}
} // namespace ucbhelper