libzypp 17.35.14
Url.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
13#include <zypp-core/Url.h>
14#include <zypp-core/Pathname.h>
18#include <stdexcept>
19#include <iostream>
20#include <utility>
21
22
24namespace zypp
25{
26
27
28 using namespace zypp::url;
29
30
31 // -----------------------------------------------------------------
32 /*
33 * url = [scheme:] [//authority] /path [?query] [#fragment]
34 */
35 #define RX_SPLIT_URL "^([^:/?#]+:|)" \
36 "(//[^/?#]*|)" \
37 "([^?#]*)" \
38 "([?][^#]*|)" \
39 "(#.*|)"
40
41
43 namespace
44 {
45
46
47 // ---------------------------------------------------------------
48 class LDAPUrl: public UrlBase
49 {
50 public:
51 LDAPUrl(): UrlBase()
52 {
53 configure();
54 }
55
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;
61
62 UrlBase *
63 clone() const override
64 {
65 return new LDAPUrl(*this);
66 }
67
69 getKnownSchemes() const override
70 {
71 UrlSchemes schemes(2);
72 schemes[0] = "ldap";
73 schemes[1] = "ldaps";
74 return schemes;
75 }
76
77 void
78 configure() override
79 {
80 config("sep_pathparams", "");
81
82 config("psep_querystr", "?");
83 config("vsep_querystr", "");
84
85 // host is required (isValid=>false)
86 // but not mandatory (see RFC 2255),
87 // that is, accept empty host.
88 config("require_host", "y");
89
90 // not allowed here
91 config("rx_username", "");
92 config("rx_password", "");
93 config("rx_fragment", "");
94 config("rx_pathparams", "");
95 }
96
98 getQueryStringMap(zypp::url::EEncoding eflag) const override
99 {
100 static const char * const keys[] = {
101 "attrs", "scope", "filter", "exts", NULL
102 };
104 zypp::url::ParamVec pvec( getQueryStringVec());
105 if( pvec.size() <= 4)
106 {
107 for(size_t i=0; i<pvec.size(); i++)
108 {
109 if(eflag == zypp::url::E_ENCODED)
110 pmap[keys[i]] = pvec[i];
111 else
112 pmap[keys[i]] = zypp::url::decode( pvec[i]);
113 }
114 }
115 else
116 {
118 _("Invalid LDAP URL query string")
119 ));
120 }
121 return pmap;
122 }
123
124 void
125 setQueryStringMap(const zypp::url::ParamMap &pmap) override
126 {
127 static const char * const keys[] = {
128 "attrs", "scope", "filter", "exts", NULL
129 };
130
131 // remove psep ("?") from safe chars
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++)
136 {
137 if( psep.find(safe[i]) == std::string::npos)
138 join_safe.append(1, safe[i]);
139 }
140
141 zypp::url::ParamVec pvec(4);
142 zypp::url::ParamMap::const_iterator p;
143 for(p=pmap.begin(); p!=pmap.end(); ++p)
144 {
145 bool found=false;
146 for(size_t i=0; i<4; i++)
147 {
148 if(p->first == keys[i])
149 {
150 found=true;
151 pvec[i] = zypp::url::encode(p->second, join_safe);
152 }
153 }
154 if( !found)
155 {
157 str::form(_("Invalid LDAP URL query parameter '%s'"),
158 p->first.c_str())
159 ));
160 }
161 }
162 setQueryStringVec(pvec);
163 }
164 };
165
166
167 // ---------------------------------------------------------------
168 // FIXME: hmm..
169 class UrlByScheme
170 {
171 private:
172 using UrlBySchemeMap = std::map<std::string, UrlRef>;
173 UrlBySchemeMap urlByScheme;
174
175 public:
176 UrlByScheme()
177 {
178 UrlRef ref;
179
180 // =====================================
181 ref.reset( new LDAPUrl());
182 addUrlByScheme("ldap", ref);
183 addUrlByScheme("ldaps", ref);
184
185
186 // =====================================
187 ref.reset( new UrlBase());
188 // don't show empty authority
189 ref->setViewOptions( zypp::url::ViewOption::DEFAULTS -
190 zypp::url::ViewOption::EMPTY_AUTHORITY);
191
192 ref->config("with_authority", "n"); // disallow host,...
193 ref->config("require_pathname", "m"); // path is mandatory
194 addUrlByScheme("hd", ref);
195 addUrlByScheme("cd", ref);
196 addUrlByScheme("dvd", ref);
197 addUrlByScheme("dir", ref);
198 addUrlByScheme("iso", ref);
199
200 addUrlByScheme("mailto", ref);
201 addUrlByScheme("urn", ref);
202 addUrlByScheme("plugin", ref); // zypp plugable media handler:
203
204 // RFC1738, 3.10: may contain a host
205 ref->config("with_authority", "y"); // allow host,
206 ref->config("with_port", "n"); // but no port,
207 ref->config("rx_username", ""); // username or
208 ref->config("rx_password", ""); // password ...
209 addUrlByScheme("file", ref);
210
211 // =====================================
212 ref.reset( new UrlBase());
213 ref->config("require_host", "m"); // host is mandatory
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"); // always encode 2. slash
221 addUrlByScheme("ftp", ref);
222 addUrlByScheme("sftp", ref);
223 addUrlByScheme("tftp", ref);
224 }
225
226 bool
227 addUrlByScheme(const std::string &scheme,
228 UrlRef urlImpl)
229 {
230 if( urlImpl && urlImpl->isValidScheme(scheme))
231 {
232 UrlRef ref(urlImpl);
233 ref->clear();
234 urlByScheme[str::toLower(scheme)] = ref;
235 return true;
236 }
237 return false;
238 }
239
240 UrlRef
241 getUrlByScheme(const std::string &scheme) const
242 {
243 UrlBySchemeMap::const_iterator i(urlByScheme.find(str::toLower(scheme)));
244 if( i != urlByScheme.end())
245 {
246 return i->second;
247 }
248 return UrlRef();
249 }
250
251 bool
252 isRegisteredScheme(const std::string &scheme) const
253 {
254 return urlByScheme.find(str::toLower(scheme)) != urlByScheme.end();
255 }
256
258 getRegisteredSchemes() const
259 {
260 UrlBySchemeMap::const_iterator i(urlByScheme.begin());
261 UrlSchemes schemes;
262
263 schemes.reserve(urlByScheme.size());
264 for( ; i != urlByScheme.end(); ++i)
265 {
266 schemes.push_back(i->first);
267 }
268 return schemes;
269 }
270 };
271
272
273 // ---------------------------------------------------------------
274 UrlByScheme & g_urlSchemeRepository()
275 {
276 static UrlByScheme _v;
277 return _v;
278 }
279
281 } // anonymous namespace
283
284
285 // -----------------------------------------------------------------
287 {
288 }
289
290
291 // -----------------------------------------------------------------
293 : m_impl( new UrlBase())
294 {
295 }
296
297
298 // -----------------------------------------------------------------
299 Url::Url(const Url &url)
300 : m_impl( url.m_impl)
301 {
302 if( !m_impl)
303 {
305 _("Unable to clone Url object")
306 ));
307 }
308 }
309
310
311 // -----------------------------------------------------------------
313 : m_impl(std::move( url))
314 {
315 if( !m_impl)
316 {
318 _("Invalid empty Url object reference")
319 ));
320 }
321 }
322
323
324 // -----------------------------------------------------------------
325 Url::Url(const std::string &encodedUrl)
326 : m_impl( parseUrl(encodedUrl))
327 {
328 if( !m_impl)
329 {
331 _("Unable to parse Url components")
332 ));
333 }
334 }
335
336
337 // -----------------------------------------------------------------
338 Url&
339 Url::operator = (const std::string &encodedUrl)
340 {
341 UrlRef url( parseUrl(encodedUrl));
342 if( !url)
343 {
345 _("Unable to parse Url components")
346 ));
347 }
348 m_impl = url;
349 return *this;
350 }
351
352
353 // -----------------------------------------------------------------
354 Url&
356 {
357 m_impl = url.m_impl;
358 return *this;
359 }
360
361
362 // -----------------------------------------------------------------
363 // static
364 bool
365 Url::registerScheme(const std::string &scheme,
366 UrlRef urlImpl)
367 {
368 return g_urlSchemeRepository().addUrlByScheme(scheme, std::move(urlImpl));
369 }
370
371
372 // -----------------------------------------------------------------
373 // static
374 UrlRef
375 Url::parseUrl(const std::string &encodedUrl)
376 {
377 UrlRef url;
378 str::smatch out;
379 bool ret = false;
380
381 try
382 {
384 ret = str::regex_match(encodedUrl, out, rex);
385 }
386 catch( ... )
387 {}
388
389 if(ret && out.size() == 6)
390 {
391 std::string scheme = out[1];
392 if (scheme.size() > 1)
393 scheme.pop_back();
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);
403
404 url = g_urlSchemeRepository().getUrlByScheme(scheme);
405 if( !url)
406 {
407 url.reset( new UrlBase());
408 }
409 url->init(scheme, authority, out[3],
410 query, fragment);
411 }
412 return url;
413 }
414
415
416 // -----------------------------------------------------------------
417 // static
420 {
421 return g_urlSchemeRepository().getRegisteredSchemes();
422 }
423
424
425 // -----------------------------------------------------------------
426 // static
427 bool
428 Url::isRegisteredScheme(const std::string &scheme)
429 {
430 return g_urlSchemeRepository().isRegisteredScheme(scheme);
431 }
432
433
434 // -----------------------------------------------------------------
437 {
438 return m_impl->getKnownSchemes();
439 }
440
441
442 // -----------------------------------------------------------------
443 bool
444 Url::isValidScheme(const std::string &scheme) const
445 {
446 return m_impl->isValidScheme(scheme);
447 }
448
449
451 namespace
452 {
453 inline bool isInList( const char ** begin_r, const char ** end_r, const std::string & scheme_r )
454 {
455 for ( ; begin_r != end_r; ++begin_r )
456 if ( scheme_r == *begin_r )
457 return true;
458 return false;
459 }
460 }
461 bool Url::schemeIsLocal( const std::string & scheme_r )
462 {
463 static const char * val[] = { "cd", "dvd", "dir", "hd", "iso", "file" };
464 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
465 }
466
467 bool Url::schemeIsRemote( const std::string & scheme_r )
468 {
469 static const char * val[] = { "http", "https", "nfs", "nfs4", "smb", "cifs", "ftp", "sftp", "tftp" };
470 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
471 }
472
473 bool Url::schemeIsVolatile( const std::string & scheme_r )
474 {
475 static const char * val[] = { "cd", "dvd" };
476 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
477 }
478
479 bool Url::schemeIsDownloading( const std::string & scheme_r )
480 {
481 static const char * val[] = { "http", "https", "ftp", "sftp", "tftp" };
482 return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
483 }
484
485 bool Url::schemeIsPlugin( const std::string & scheme_r )
486 {
487 return scheme_r == "plugin";
488 }
490
491 // -----------------------------------------------------------------
492 bool
494 {
495 return m_impl->isValid();
496 }
497
498
499 // -----------------------------------------------------------------
500 std::string
502 {
503 return m_impl->asString();
504 }
505
506
507 // -----------------------------------------------------------------
508 std::string
510 {
511 // make sure, all url components are included;
512 // regardless of the current configuration...
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);
523 return m_impl->asString(opts);
524 }
525
526
527 // -----------------------------------------------------------------
528 std::string
529 Url::asString(const ViewOptions &opts) const
530 {
531 return m_impl->asString(opts);
532 }
533
534
535 // -----------------------------------------------------------------
536 std::string
538 {
539 return m_impl->getScheme();
540 }
541
542
543 // -----------------------------------------------------------------
544 std::string
546 {
547 return m_impl->getAuthority();
548 }
549
550 // -----------------------------------------------------------------
551 std::string
553 {
554 return m_impl->getPathData();
555 }
556
557
558 // -----------------------------------------------------------------
559 std::string
561 {
562 return m_impl->getQueryString();
563 }
564
565
566 // -----------------------------------------------------------------
567 std::string
569 {
570 return m_impl->getFragment(eflag);
571 }
572
573
574 // -----------------------------------------------------------------
575 std::string
577 {
578 return m_impl->getUsername(eflag);
579 }
580
581
582 // -----------------------------------------------------------------
583 std::string
585 {
586 return m_impl->getPassword(eflag);
587 }
588
589
590 // -----------------------------------------------------------------
591 std::string
593 {
594 return m_impl->getHost(eflag);
595 }
596
597
598 // -----------------------------------------------------------------
599 std::string
601 {
602 return m_impl->getPort();
603 }
604
605
606 // -----------------------------------------------------------------
607 std::string
609 {
610 return m_impl->getPathName(eflag);
611 }
612
613
614 // -----------------------------------------------------------------
615 std::string
617 {
618 return m_impl->getPathParams();
619 }
620
621
622 // -----------------------------------------------------------------
625 {
626 return m_impl->getPathParamsVec();
627 }
628
629
630 // -----------------------------------------------------------------
633 {
634 return m_impl->getPathParamsMap(eflag);
635 }
636
637
638 // -----------------------------------------------------------------
639 std::string
640 Url::getPathParam(const std::string &param, EEncoding eflag) const
641 {
642 return m_impl->getPathParam(param, eflag);
643 }
644
645
646 // -----------------------------------------------------------------
649 {
650 return m_impl->getQueryStringVec();
651 }
652
653
654 // -----------------------------------------------------------------
657 {
658 return m_impl->getQueryStringMap(eflag);
659 }
660
661
662 // -----------------------------------------------------------------
663 std::string
664 Url::getQueryParam(const std::string &param, EEncoding eflag) const
665 {
666 return m_impl->getQueryParam(param, eflag);
667 }
668
669
670 // -----------------------------------------------------------------
671 void
672 Url::setScheme(const std::string &scheme)
673 {
674 if(scheme == m_impl->getScheme())
675 {
676 return;
677 }
678 if( m_impl->isKnownScheme(scheme))
679 {
680 m_impl->setScheme(scheme);
681 return;
682 }
683
684 UrlRef url = g_urlSchemeRepository().getUrlByScheme(scheme);
685 if( !url)
686 {
687 url.reset( new UrlBase());
688 }
689 url->init(
690 scheme,
695 );
696 m_impl = url;
697 }
698
699
700 // -----------------------------------------------------------------
701 void
702 Url::setAuthority(const std::string &authority)
703 {
704 m_impl->setAuthority(authority);
705 }
706
707
708 // -----------------------------------------------------------------
709 void
710 Url::setPathData(const std::string &pathdata)
711 {
712 m_impl->setPathData(pathdata);
713 }
714
715
716 // -----------------------------------------------------------------
717 void
718 Url::setQueryString(const std::string &querystr)
719 {
720 m_impl->setQueryString(querystr);
721 }
722
723
724 // -----------------------------------------------------------------
725 void
726 Url::setFragment(const std::string &fragment, EEncoding eflag)
727 {
728 m_impl->setFragment(fragment, eflag);
729 }
730
731
732 // -----------------------------------------------------------------
733 void
734 Url::setUsername(const std::string &user,
735 EEncoding eflag)
736 {
737 m_impl->setUsername(user, eflag);
738 }
739
740
741 // -----------------------------------------------------------------
742 void
743 Url::setPassword(const std::string &pass,
744 EEncoding eflag)
745 {
746 m_impl->setPassword(pass, eflag);
747 }
748
749
750 // -----------------------------------------------------------------
751 void
752 Url::setHost(const std::string &host)
753 {
754 m_impl->setHost(host);
755 }
756
757
758 // -----------------------------------------------------------------
759 void
760 Url::setPort(const std::string &port)
761 {
762 m_impl->setPort(port);
763 }
764
765
766 // -----------------------------------------------------------------
767 void
768 Url::setPathName(const std::string &path,
769 EEncoding eflag)
770 {
771 m_impl->setPathName(path, eflag);
772 }
773
774 void
776 EEncoding eflag)
777 {
778 m_impl->setPathName(path.asString(), eflag);
779 }
780
781 void
782 Url::setPathName(const char *path,
783 EEncoding eflag)
784 {
785 m_impl->setPathName(path, eflag);
786 }
787
788 // -----------------------------------------------------------------
789
790 void Url::appendPathName( const Pathname & path_r, EEncoding eflag_r )
791 { if ( ! path_r.emptyOrRoot() ) setPathName( Pathname(getPathName( eflag_r )) / path_r, eflag_r ); }
792
793 // -----------------------------------------------------------------
794 void
795 Url::setPathParams(const std::string &params)
796 {
797 m_impl->setPathParams(params);
798 }
799
800
801 // -----------------------------------------------------------------
802 void
807
808
809 // -----------------------------------------------------------------
810 void
815
816
817 // -----------------------------------------------------------------
818 void
819 Url::setPathParam(const std::string &param, const std::string &value)
820 {
821 m_impl->setPathParam(param, value);
822 }
823
824
825 // -----------------------------------------------------------------
826 void
831
832
833 // -----------------------------------------------------------------
834 void
839
840 // -----------------------------------------------------------------
841 void
842 Url::setQueryParam(const std::string &param, const std::string &value)
843 {
844 m_impl->setQueryParam(param, value);
845 }
846
847 // -----------------------------------------------------------------
848 void
849 Url::delQueryParam(const std::string &param)
850 {
851 m_impl->delQueryParam(param);
852 }
853
854 // -----------------------------------------------------------------
857 {
858 return m_impl->getViewOptions();
859 }
860
861 // -----------------------------------------------------------------
862 void
864 {
865 m_impl->setViewOptions(vopts);
866 }
867
868 // -----------------------------------------------------------------
869 std::ostream & operator<<( std::ostream & str, const Url & url )
870 {
871 return str << url.asString();
872 }
873
874 bool operator<( const Url &lhs, const Url &rhs )
875 {
876 return (lhs.asCompleteString() < rhs.asCompleteString());
877 }
878
879 bool operator==( const Url &lhs, const Url &rhs )
880 {
881 return (lhs.asCompleteString() == rhs.asCompleteString());
882 }
883
884 bool operator!=( const Url &lhs, const Url &rhs )
885 {
886 return (lhs.asCompleteString() != rhs.asCompleteString());
887 }
888
889 namespace hotfix1050625 {
890 std::string asString( const Url & url_r )
891 { return url_r.m_impl->asString1050625(); }
892 }
893
895} // namespace zypp
897/*
898** vim: set ts=2 sts=2 sw=2 ai et:
899*/
#define RX_SPLIT_URL
Definition Url.cc:35
UrlBySchemeMap urlByScheme
Definition Url.cc:173
Url manipulation class.
Definition Url.h:92
bool schemeIsPlugin() const
Definition Url.h:293
std::string getScheme() const
Returns the scheme name of the URL.
Definition Url.cc:537
std::string asCompleteString() const
Returns a complete string representation of the Url object.
Definition Url.cc:509
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition Url.cc:863
void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition Url.cc:702
zypp::url::ParamMap getPathParamsMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with path parameter keys and values.
Definition Url.cc:632
zypp::url::ParamVec getPathParamsVec() const
Returns a vector with path parameter substrings.
Definition Url.cc:624
void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition Url.cc:718
bool schemeIsRemote() const
Definition Url.h:278
std::string getPathParams() const
Returns the path parameters from the URL.
Definition Url.cc:616
std::string asString() const
Returns a default string representation of the Url object.
Definition Url.cc:501
std::string getPathData() const
Returns the encoded path component of the URL.
Definition Url.cc:552
std::string getPathParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified path parameter.
Definition Url.cc:640
std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition Url.cc:545
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition Url.cc:576
static bool isRegisteredScheme(const std::string &scheme)
Returns if scheme name is registered.
Definition Url.cc:428
void setFragment(const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED)
Set the fragment string in the URL.
Definition Url.cc:726
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition Url.cc:608
void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition Url.cc:827
Url()
Definition Url.cc:292
std::string getQueryParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
Definition Url.cc:664
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
Definition Url.cc:768
void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition Url.cc:811
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition Url.cc:856
bool schemeIsDownloading() const
Definition Url.h:288
void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition Url.cc:710
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
Definition Url.cc:592
url::UrlRef m_impl
Definition Url.h:846
void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition Url.cc:752
void setPort(const std::string &port)
Set the port number in the URL authority.
Definition Url.cc:760
~Url()
Definition Url.cc:286
void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition Url.cc:849
void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition Url.cc:803
bool isValid() const
Verifies the Url.
Definition Url.cc:493
std::string getFragment(EEncoding eflag=zypp::url::E_DECODED) const
Returns the encoded fragment component of the URL.
Definition Url.cc:568
static url::UrlRef parseUrl(const std::string &encodedUrl)
Parse a percent-encoded URL string.
Definition Url.cc:375
void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition Url.cc:819
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
Definition Url.cc:743
void setPathParams(const std::string &params)
Set the path parameters.
Definition Url.cc:795
Url & operator=(const std::string &encodedUrl)
Assigns parsed percent-encoded URL string to the object.
Definition Url.cc:339
static bool registerScheme(const std::string &scheme, url::UrlRef urlImpl)
Register a scheme-specific implementation.
Definition Url.cc:365
std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition Url.cc:560
bool isValidScheme(const std::string &scheme) const
Verifies the specified scheme name.
Definition Url.cc:444
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition Url.cc:842
static zypp::url::UrlSchemes getRegisteredSchemes()
Returns all registered scheme names.
Definition Url.cc:419
zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition Url.cc:648
bool schemeIsLocal() const
Definition Url.h:273
void setUsername(const std::string &user, EEncoding eflag=zypp::url::E_DECODED)
Set the username in the URL authority.
Definition Url.cc:734
zypp::url::UrlSchemes getKnownSchemes() const
Returns scheme names known to this object.
Definition Url.cc:436
void appendPathName(const Pathname &path_r, EEncoding eflag_r=zypp::url::E_DECODED)
Extend the path name.
Definition Url.cc:790
void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition Url.cc:672
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition Url.cc:584
bool schemeIsVolatile() const
Definition Url.h:283
zypp::url::ParamMap getQueryStringMap(EEncoding eflag=zypp::url::E_DECODED) const
Returns a string map with query parameter and their values.
Definition Url.cc:656
std::string getPort() const
Returns the port from the URL authority.
Definition Url.cc:600
void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition Url.cc:835
bool emptyOrRoot() const
Test for "" or "/".
Definition Pathname.h:123
const std::string & asString() const
String representation.
Definition Pathname.h:93
Regular expression.
Definition Regex.h:95
Regular expression match result.
Definition Regex.h:168
unsigned size() const
Definition Regex.cc:106
Generic Url base class.
Definition UrlBase.h:271
virtual void setQueryString(const std::string &querystr)
Set the query string in the URL.
Definition UrlBase.cc:969
virtual std::string getQueryString() const
Returns the encoded query string component of the URL.
Definition UrlBase.cc:698
virtual std::string getPort() const
Returns the port number from the URL authority.
Definition UrlBase.cc:755
virtual void setScheme(const std::string &scheme)
Set the scheme name in the URL.
Definition UrlBase.cc:892
virtual void setHost(const std::string &host)
Set the hostname or IP in the URL authority.
Definition UrlBase.cc:1081
virtual zypp::url::ParamMap getPathParamsMap(EEncoding eflag) const
Returns a string map with path parameter keys and values.
Definition UrlBase.cc:803
virtual zypp::url::ParamVec getPathParamsVec() const
Returns a vector with encoded path parameter substrings.
Definition UrlBase.cc:782
virtual std::string getUsername(EEncoding eflag) const
Returns the username from the URL authority.
Definition UrlBase.cc:722
virtual UrlSchemes getKnownSchemes() const
Returns scheme names known by this object.
Definition UrlBase.cc:416
virtual std::string getAuthority() const
Returns the encoded authority component of the URL.
Definition UrlBase.cc:661
virtual void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition UrlBase.cc:1322
std::string config(const std::string &opt) const
Get the value of a UrlBase configuration variable.
Definition UrlBase.cc:368
virtual void setPathParamsVec(const zypp::url::ParamVec &pvec)
Set the path parameters.
Definition UrlBase.cc:1243
virtual std::string getFragment(EEncoding eflag) const
Returns the encoded fragment component of the URL.
Definition UrlBase.cc:711
virtual std::string getPathParams() const
Returns the encoded path parameters from the URL.
Definition UrlBase.cc:774
virtual void setQueryStringMap(const zypp::url::ParamMap &qmap)
Set the query parameters.
Definition UrlBase.cc:1301
virtual std::string getPassword(EEncoding eflag) const
Returns the password from the URL authority.
Definition UrlBase.cc:733
virtual std::string getScheme() const
Returns the scheme name of the URL.
Definition UrlBase.cc:653
virtual zypp::url::ParamMap getQueryStringMap(EEncoding eflag) const
Returns a string map with query parameter and their values.
Definition UrlBase.cc:858
virtual void setUsername(const std::string &user, EEncoding eflag)
Set the username in the URL authority.
Definition UrlBase.cc:1013
virtual std::string getPathParam(const std::string &param, EEncoding eflag) const
Return the value for the specified path parameter.
Definition UrlBase.cc:826
virtual void setPathParamsMap(const zypp::url::ParamMap &pmap)
Set the path parameters.
Definition UrlBase.cc:1256
virtual std::string asString() const
Returns a default string representation of the Url object.
Definition UrlBase.cc:505
virtual bool isKnownScheme(const std::string &scheme) const
Returns if scheme name is known to this object.
Definition UrlBase.cc:424
virtual std::string getHost(EEncoding eflag) const
Returns the hostname or IP from the URL authority.
Definition UrlBase.cc:744
virtual void setPathData(const std::string &pathdata)
Set the path data component in the URL.
Definition UrlBase.cc:944
virtual void setPathName(const std::string &path, EEncoding eflag)
Set the path name.
Definition UrlBase.cc:1166
virtual void setPort(const std::string &port)
Set the port number in the URL authority.
Definition UrlBase.cc:1134
virtual std::string getPathData() const
Returns the encoded path component of the URL.
Definition UrlBase.cc:688
virtual bool isValid() const
Verifies the Url.
Definition UrlBase.cc:473
virtual std::string getPathName(EEncoding eflag) const
Returns the path name from the URL.
Definition UrlBase.cc:763
virtual void setFragment(const std::string &fragment, EEncoding eflag)
Set the fragment string in the URL.
Definition UrlBase.cc:986
virtual bool isValidScheme(const std::string &scheme) const
Verifies specified scheme name.
Definition UrlBase.cc:441
virtual zypp::url::ParamVec getQueryStringVec() const
Returns a vector with query string parameter substrings.
Definition UrlBase.cc:837
virtual std::string getQueryParam(const std::string &param, EEncoding eflag) const
Return the value for the specified query parameter.
Definition UrlBase.cc:881
void setViewOptions(const ViewOptions &vopts)
Change the view options of the current object.
Definition UrlBase.cc:388
virtual void setQueryStringVec(const zypp::url::ParamVec &qvec)
Set the query parameters.
Definition UrlBase.cc:1288
virtual void delQueryParam(const std::string &param)
remove the specified query parameter.
Definition UrlBase.cc:1331
virtual void setPassword(const std::string &pass, EEncoding eflag)
Set the password in the URL authority.
Definition UrlBase.cc:1047
virtual void setPathParam(const std::string &param, const std::string &value)
Set or add value for the specified path parameter.
Definition UrlBase.cc:1278
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.
Definition UrlBase.cc:295
virtual void setPathParams(const std::string &params)
Set the path parameters.
Definition UrlBase.cc:1226
std::string asString1050625() const
Definition UrlBase.cc:510
virtual void setAuthority(const std::string &authority)
Set the authority component in the URL.
Definition UrlBase.cc:916
ViewOptions getViewOptions() const
Return the view options of the current object.
Definition UrlBase.cc:380
Base class for all URL exceptions.
Thrown if the url or a component can't be parsed at all.
Definition Arch.h:364
String related utilities and Regular expression matching.
std::string asString(const Url &url_r)
Definition Url.cc:890
std::string toLower(const std::string &s)
Return lowercase version of s.
Definition String.cc:178
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition Regex.h:70
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
Url details namespace.
Definition UrlBase.cc:58
RWCOW_pointer< UrlBase > UrlRef
Copy-On-Write Url reference.
Definition UrlBase.h:1089
std::string encode(const std::string &str, const std::string &safe, EEncoding eflag)
Encodes a string using URL percent encoding.
Definition UrlUtils.cc:32
std::vector< std::string > ParamVec
A parameter vector container.
Definition UrlUtils.h:40
std::map< std::string, std::string > ParamMap
A parameter map container.
Definition UrlUtils.h:47
std::vector< std::string > UrlSchemes
Vector of URL scheme names.
Definition UrlBase.h:251
EEncoding
Encoding flags.
Definition UrlUtils.h:52
@ E_ENCODED
Flag to request encoded string(s).
Definition UrlUtils.h:53
std::string decode(const std::string &str, bool allowNUL)
Decodes a URL percent encoded string.
Definition UrlUtils.cc:87
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.
Definition UrlBase.h:40
#define arrayBegin(A)
Simple C-array iterator.
Definition Easy.h:41
#define arrayEnd(A)
Definition Easy.h:43
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:424
#define _(MSG)
Definition Gettext.h:39