35 #define RX_SPLIT_URL "^([^:/?#]+:|)" \
56 LDAPUrl(LDAPUrl &&) =
default;
57 LDAPUrl &operator=(
const LDAPUrl &) =
default;
58 LDAPUrl &operator=(LDAPUrl &&) =
default;
59 LDAPUrl(
const LDAPUrl &url) :
UrlBase(url) {}
60 ~LDAPUrl()
override =
default;
63 clone()
const override
65 return new LDAPUrl(*
this);
69 getKnownSchemes()
const override
80 config(
"sep_pathparams",
"");
82 config(
"psep_querystr",
"?");
83 config(
"vsep_querystr",
"");
88 config(
"require_host",
"y");
91 config(
"rx_username",
"");
92 config(
"rx_password",
"");
93 config(
"rx_fragment",
"");
94 config(
"rx_pathparams",
"");
100 static const char *
const keys[] = {
101 "attrs",
"scope",
"filter",
"exts", NULL
105 if( pvec.size() <= 4)
107 for(
size_t i=0; i<pvec.size(); i++)
110 pmap[keys[i]] = pvec[i];
118 _(
"Invalid LDAP URL query string")
127 static const char *
const keys[] = {
128 "attrs",
"scope",
"filter",
"exts", NULL
132 std::string join_safe;
133 std::string safe(config(
"safe_querystr"));
134 std::string psep(config(
"psep_querystr"));
135 for(std::string::size_type i=0; i<safe.size(); i++)
137 if( psep.find(safe[i]) == std::string::npos)
138 join_safe.append(1, safe[i]);
142 zypp::url::ParamMap::const_iterator p;
143 for(p=pmap.begin(); p!=pmap.end(); ++p)
146 for(
size_t i=0; i<4; i++)
148 if(p->first == keys[i])
157 str::form(
_(
"Invalid LDAP URL query parameter '%s'"),
162 setQueryStringVec(pvec);
172 using UrlBySchemeMap = std::map<std::string, UrlRef>;
181 ref.
reset(
new LDAPUrl());
182 addUrlByScheme(
"ldap", ref);
183 addUrlByScheme(
"ldaps", ref);
190 zypp::url::ViewOption::EMPTY_AUTHORITY);
192 ref->
config(
"with_authority",
"n");
193 ref->
config(
"require_pathname",
"m");
194 addUrlByScheme(
"hd", ref);
195 addUrlByScheme(
"cd", ref);
196 addUrlByScheme(
"dvd", ref);
197 addUrlByScheme(
"dir", ref);
198 addUrlByScheme(
"iso", ref);
200 addUrlByScheme(
"mailto", ref);
201 addUrlByScheme(
"urn", ref);
202 addUrlByScheme(
"plugin", ref);
205 ref->
config(
"with_authority",
"y");
206 ref->
config(
"with_port",
"n");
207 ref->
config(
"rx_username",
"");
208 ref->
config(
"rx_password",
"");
209 addUrlByScheme(
"file", ref);
213 ref->
config(
"require_host",
"m");
214 addUrlByScheme(
"nfs", ref);
215 addUrlByScheme(
"nfs4", ref);
216 addUrlByScheme(
"smb", ref);
217 addUrlByScheme(
"cifs", ref);
218 addUrlByScheme(
"http", ref);
219 addUrlByScheme(
"https", ref);
220 ref->
config(
"path_encode_slash2",
"y");
221 addUrlByScheme(
"ftp", ref);
222 addUrlByScheme(
"sftp", ref);
223 addUrlByScheme(
"tftp", ref);
227 addUrlByScheme(
const std::string &scheme,
241 getUrlByScheme(
const std::string &scheme)
const
252 isRegisteredScheme(
const std::string &scheme)
const
258 getRegisteredSchemes()
const
260 UrlBySchemeMap::const_iterator i(
urlByScheme.begin());
266 schemes.push_back(i->first);
274 UrlByScheme & g_urlSchemeRepository()
276 static UrlByScheme _v;
300 : m_impl( url.m_impl)
305 _(
"Unable to clone Url object")
313 : m_impl(
std::move( url))
318 _(
"Invalid empty Url object reference")
326 : m_impl( parseUrl(encodedUrl))
331 _(
"Unable to parse Url components")
345 _(
"Unable to parse Url components")
368 return g_urlSchemeRepository().addUrlByScheme(scheme, std::move(urlImpl));
389 if(ret && out.
size() == 6)
391 std::string scheme = out[1];
392 if (scheme.size() > 1)
393 scheme = scheme.substr(0, scheme.size()-1);
394 std::string authority = out[2];
395 if (authority.size() >= 2)
396 authority = authority.substr(2);
397 std::string query = out[4];
398 if (query.size() > 1)
399 query = query.substr(1);
400 std::string fragment = out[5];
401 if (fragment.size() > 1)
402 fragment = fragment.substr(1);
404 url = g_urlSchemeRepository().getUrlByScheme(scheme);
409 url->
init(scheme, authority, out[3],
421 return g_urlSchemeRepository().getRegisteredSchemes();
430 return g_urlSchemeRepository().isRegisteredScheme(scheme);
453 inline bool isInList(
const char ** begin_r,
const char ** end_r,
const std::string & scheme_r )
455 for ( ; begin_r != end_r; ++begin_r )
456 if ( scheme_r == *begin_r )
463 static const char * val[] = {
"cd",
"dvd",
"dir",
"hd",
"iso",
"file" };
469 static const char * val[] = {
"http",
"https",
"nfs",
"nfs4",
"smb",
"cifs",
"ftp",
"sftp",
"tftp" };
475 static const char * val[] = {
"cd",
"dvd" };
481 static const char * val[] = {
"http",
"https",
"ftp",
"sftp",
"tftp" };
487 return scheme_r ==
"plugin";
514 ViewOption::WITH_SCHEME +
515 ViewOption::WITH_USERNAME +
516 ViewOption::WITH_PASSWORD +
517 ViewOption::WITH_HOST +
518 ViewOption::WITH_PORT +
519 ViewOption::WITH_PATH_NAME +
520 ViewOption::WITH_PATH_PARAMS +
521 ViewOption::WITH_QUERY_STR +
522 ViewOption::WITH_FRAGMENT);
684 UrlRef url = g_urlSchemeRepository().getUrlByScheme(scheme);
889 namespace hotfix1050625 {
UrlBySchemeMap urlByScheme
bool schemeIsPlugin() const
std::string getScheme() const
Returns the scheme name of the URL.
std::string asCompleteString() const
Returns a complete string representation of the Url object.
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
void setAuthority(const std::string &authority)
Set the authority component in the URL.
zypp::url::ParamMap getPathParamsMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with path parameter keys and values.
zypp::url::ParamVec getPathParamsVec() const
Returns a vector with path parameter substrings.
void setQueryString(const std::string &querystr)
Set the query string in the URL.
bool schemeIsRemote() const
std::string getPathParams() const
Returns the path parameters from the URL.
std::string asString() const
Returns a default string representation of the Url object.
std::string getPathData() const
Returns the encoded path component of the URL.
std::string getPathParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified path parameter.
std::string getAuthority() const
Returns the encoded authority component of the URL.
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
static bool isRegisteredScheme(const std::string &scheme)
Returns if scheme name is registered.
void setFragment(const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED)
Set the fragment string in the URL.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
ViewOptions getViewOptions() const
Return the view options of the current object.
bool schemeIsDownloading() const
void setPathData(const std::string &pathdata)
Set the path data component in the URL.
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
void setPort(const std::string &port)
Set the port number in the URL authority.
void delQueryParam(const std::string ¶m)
remove the specified query parameter.
void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
bool isValid() const
Verifies the Url.
std::string getFragment(EEncoding eflag=zypp::url::E_DECODED) const
Returns the encoded fragment component of the URL.
static url::UrlRef parseUrl(const std::string &encodedUrl)
Parse a percent-encoded URL string.
void setPathParam(const std::string ¶m, const std::string &value)
Set or add value for the specified path parameter.
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
void setPathParams(const std::string ¶ms)
Set the path parameters.
Url & operator=(const std::string &encodedUrl)
Assigns parsed percent-encoded URL string to the object.
static bool registerScheme(const std::string &scheme, url::UrlRef urlImpl)
Register a scheme-specific implementation.
std::string getQueryString() const
Returns the encoded query string component of the URL.
bool isValidScheme(const std::string &scheme) const
Verifies the specified scheme name.
void setQueryParam(const std::string ¶m, const std::string &value)
Set or add value for the specified query parameter.
static zypp::url::UrlSchemes getRegisteredSchemes()
Returns all registered scheme names.
zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
bool schemeIsLocal() const
void setUsername(const std::string &user, EEncoding eflag=zypp::url::E_DECODED)
Set the username in the URL authority.
zypp::url::UrlSchemes getKnownSchemes() const
Returns scheme names known to this object.
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
bool schemeIsVolatile() const
zypp::url::ParamMap getQueryStringMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with query parameter and their values.
std::string getPort() const
Returns the port from the URL authority.
void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
bool emptyOrRoot() const
Test for "" or "/".
const std::string & asString() const
String representation.
Regular expression match result.
virtual void setQueryString(const std::string &querystr)
Set the query string in the URL.
virtual std::string getQueryString() const
Returns the encoded query string component of the URL.
virtual std::string getPort() const
Returns the port number from the URL authority.
virtual void setScheme(const std::string &scheme)
Set the scheme name in the URL.
virtual void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
virtual zypp::url::ParamMap getPathParamsMap(EEncoding eflag) const
Returns a string map with path parameter keys and values.
virtual zypp::url::ParamVec getPathParamsVec() const
Returns a vector with encoded path parameter substrings.
virtual std::string getUsername(EEncoding eflag) const
Returns the username from the URL authority.
virtual UrlSchemes getKnownSchemes() const
Returns scheme names known by this object.
virtual std::string getAuthority() const
Returns the encoded authority component of the URL.
virtual void setQueryParam(const std::string ¶m, const std::string &value)
Set or add value for the specified query parameter.
std::string config(const std::string &opt) const
Get the value of a UrlBase configuration variable.
virtual void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
virtual std::string getFragment(EEncoding eflag) const
Returns the encoded fragment component of the URL.
virtual std::string getPathParams() const
Returns the encoded path parameters from the URL.
virtual void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
virtual std::string getPassword(EEncoding eflag) const
Returns the password from the URL authority.
virtual std::string getScheme() const
Returns the scheme name of the URL.
virtual zypp::url::ParamMap getQueryStringMap(EEncoding eflag) const
Returns a string map with query parameter and their values.
virtual void setUsername(const std::string &user, EEncoding eflag)
Set the username in the URL authority.
virtual std::string getPathParam(const std::string ¶m, EEncoding eflag) const
Return the value for the specified path parameter.
virtual void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
virtual std::string asString() const
Returns a default string representation of the Url object.
virtual bool isKnownScheme(const std::string &scheme) const
Returns if scheme name is known to this object.
virtual std::string getHost(EEncoding eflag) const
Returns the hostname or IP from the URL authority.
virtual void setPathData(const std::string &pathdata)
Set the path data component in the URL.
virtual void setPathName(const std::string &path, EEncoding eflag)
Set the path name.
virtual void setPort(const std::string &port)
Set the port number in the URL authority.
virtual std::string getPathData() const
Returns the encoded path component of the URL.
virtual bool isValid() const
Verifies the Url.
virtual std::string getPathName(EEncoding eflag) const
Returns the path name from the URL.
virtual void setFragment(const std::string &fragment, EEncoding eflag)
Set the fragment string in the URL.
virtual bool isValidScheme(const std::string &scheme) const
Verifies specified scheme name.
virtual zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
virtual std::string getQueryParam(const std::string ¶m, EEncoding eflag) const
Return the value for the specified query parameter.
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
virtual void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
virtual void delQueryParam(const std::string ¶m)
remove the specified query parameter.
virtual void setPassword(const std::string &pass, EEncoding eflag)
Set the password in the URL authority.
virtual void setPathParam(const std::string ¶m, const std::string &value)
Set or add value for the specified path parameter.
virtual void init(const std::string &scheme, const std::string &authority, const std::string &pathdata, const std::string &querystr, const std::string &fragment)
Initializes current object with new URL components.
virtual void setPathParams(const std::string ¶ms)
Set the path parameters.
std::string asString1050625() const
virtual void setAuthority(const std::string &authority)
Set the authority component in the URL.
ViewOptions getViewOptions() const
Return the view options of the current object.
Base class for all URL exceptions.
Thrown if the url or a component can't be parsed at all.
String related utilities and Regular expression matching.
std::string asString(const Url &url_r)
std::string toLower(const std::string &s)
Return lowercase version of s.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
RWCOW_pointer< UrlBase > UrlRef
Copy-On-Write Url reference.
std::string encode(const std::string &str, const std::string &safe, EEncoding eflag)
Encodes a string using URL percent encoding.
std::vector< std::string > ParamVec
A parameter vector container.
std::map< std::string, std::string > ParamMap
A parameter map container.
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
@ E_ENCODED
Flag to request encoded string(s).
std::string decode(const std::string &str, bool allowNUL)
Decodes a URL percent encoded string.
Easy-to use interface to the ZYPP dependency resolver.
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
bool operator!=(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Url::asString() view options.
#define arrayBegin(A)
Simple C-array iterator.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.