KiCad PCB EDA Suite
Loading...
Searching...
No Matches
remote_provider_utils.cpp File Reference
#include <remote_provider_utils.h>
#include <wx/intl.h>
#include <wx/uri.h>

Go to the source code of this file.

Functions

wxString UrlEncode (const wxString &aValue)
 Percent-encode a string for use in URL query parameters (RFC 3986 unreserved characters are passed through unchanged).
 
wxString RemoteProviderJsonString (const nlohmann::json &aObject, const char *aKey)
 Extract an optional string value from a JSON object, returning an empty wxString when the key is absent or the value is not a string.
 
bool IsLoopbackHost (const wxString &aHost)
 Return true when aHost resolves to a loopback address (localhost, 127.0.0.1, or ::1).
 
bool ValidateRemoteUrlSecurity (const wxString &aUrl, bool aAllowInsecureLocalhost, wxString &aError, const wxString &aLabel)
 Validate that aUrl uses HTTPS, or HTTP on a loopback address when aAllowInsecureLocalhost is true.
 
wxString NormalizedUrlOrigin (const wxString &aUrl)
 Return a normalized scheme://host:port origin string for aUrl.
 

Function Documentation

◆ IsLoopbackHost()

bool IsLoopbackHost ( const wxString & aHost)

Return true when aHost resolves to a loopback address (localhost, 127.0.0.1, or ::1).

IPv6 bracket notation is handled.

Definition at line 64 of file remote_provider_utils.cpp.

Referenced by ValidateRemoteUrlSecurity().

◆ NormalizedUrlOrigin()

wxString NormalizedUrlOrigin ( const wxString & aUrl)

Return a normalized scheme://host:port origin string for aUrl.

Empty when the URL cannot be parsed.

Definition at line 100 of file remote_provider_utils.cpp.

Referenced by REMOTE_PROVIDER_CLIENT::ExchangeBootstrapNonce(), and REMOTE_PROVIDER_METADATA::FromJson().

◆ RemoteProviderJsonString()

wxString RemoteProviderJsonString ( const nlohmann::json & aObject,
const char * aKey )

◆ UrlEncode()

wxString UrlEncode ( const wxString & aValue)

Percent-encode a string for use in URL query parameters (RFC 3986 unreserved characters are passed through unchanged).

Definition at line 26 of file remote_provider_utils.cpp.

Referenced by OAUTH_SESSION::BuildAuthorizationUrl(), REMOTE_PROVIDER_CLIENT::ExchangeAuthorizationCode(), REMOTE_PROVIDER_CLIENT::RefreshAccessToken(), and REMOTE_PROVIDER_CLIENT::RevokeToken().

◆ ValidateRemoteUrlSecurity()

bool ValidateRemoteUrlSecurity ( const wxString & aUrl,
bool aAllowInsecureLocalhost,
wxString & aError,
const wxString & aLabel )

Validate that aUrl uses HTTPS, or HTTP on a loopback address when aAllowInsecureLocalhost is true.

On failure, aError is populated with a diagnostic that includes aLabel.

Definition at line 78 of file remote_provider_utils.cpp.

References _, and IsLoopbackHost().

Referenced by REMOTE_PROVIDER_CLIENT::ExchangeBootstrapNonce(), REMOTE_PROVIDER_METADATA::FromJson(), REMOTE_PROVIDER_OAUTH_SERVER_METADATA::FromJson(), and REMOTE_PROVIDER_PART_MANIFEST::FromJson().