io/qurl.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Copyright (C) 2012 Intel Corporation. -
5** Contact: http://www.qt-project.org/legal -
6** -
7** This file is part of the QtCore module of the Qt Toolkit. -
8** -
9** $QT_BEGIN_LICENSE:LGPL$ -
10** Commercial License Usage -
11** Licensees holding valid commercial Qt licenses may use this file in -
12** accordance with the commercial license agreement provided with the -
13** Software or, alternatively, in accordance with the terms contained in -
14** a written agreement between you and Digia. For licensing terms and -
15** conditions see http://qt.digia.com/licensing. For further information -
16** use the contact form at http://qt.digia.com/contact-us. -
17** -
18** GNU Lesser General Public License Usage -
19** Alternatively, this file may be used under the terms of the GNU Lesser -
20** General Public License version 2.1 as published by the Free Software -
21** Foundation and appearing in the file LICENSE.LGPL included in the -
22** packaging of this file. Please review the following information to -
23** ensure the GNU Lesser General Public License version 2.1 requirements -
24** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
25** -
26** In addition, as a special exception, Digia gives you certain additional -
27** rights. These rights are described in the Digia Qt LGPL Exception -
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
29** -
30** GNU General Public License Usage -
31** Alternatively, this file may be used under the terms of the GNU -
32** General Public License version 3.0 as published by the Free Software -
33** Foundation and appearing in the file LICENSE.GPL included in the -
34** packaging of this file. Please review the following information to -
35** ensure the GNU General Public License version 3.0 requirements will be -
36** met: http://www.gnu.org/copyleft/gpl.html. -
37** -
38** -
39** $QT_END_LICENSE$ -
40** -
41****************************************************************************/ -
42 -
43/*! -
44 \class QUrl -
45 \inmodule QtCore -
46 -
47 \brief The QUrl class provides a convenient interface for working -
48 with URLs. -
49 -
50 \reentrant -
51 \ingroup io -
52 \ingroup network -
53 \ingroup shared -
54 -
55 -
56 It can parse and construct URLs in both encoded and unencoded -
57 form. QUrl also has support for internationalized domain names -
58 (IDNs). -
59 -
60 The most common way to use QUrl is to initialize it via the -
61 constructor by passing a QString. Otherwise, setUrl() can also -
62 be used. -
63 -
64 URLs can be represented in two forms: encoded or unencoded. The -
65 unencoded representation is suitable for showing to users, but -
66 the encoded representation is typically what you would send to -
67 a web server. For example, the unencoded URL -
68 "http://b\\uuml\c{}hler.example.com" would be sent to the server as -
69 "http://xn--bhler-kva.example.com/List%20of%20applicants.xml". -
70 -
71 A URL can also be constructed piece by piece by calling -
72 setScheme(), setUserName(), setPassword(), setHost(), setPort(), -
73 setPath(), setQuery() and setFragment(). Some convenience -
74 functions are also available: setAuthority() sets the user name, -
75 password, host and port. setUserInfo() sets the user name and -
76 password at once. -
77 -
78 Call isValid() to check if the URL is valid. This can be done at -
79 any point during the constructing of a URL. -
80 -
81 Constructing a query is particularly convenient through the use of the \l -
82 QUrlQuery class and its methods QUrlQuery::setQueryItems(), -
83 QUrlQuery::addQueryItem() and QUrlQuery::removeQueryItem(). Use -
84 QUrlQuery::setQueryDelimiters() to customize the delimiters used for -
85 generating the query string. -
86 -
87 For the convenience of generating encoded URL strings or query -
88 strings, there are two static functions called -
89 fromPercentEncoding() and toPercentEncoding() which deal with -
90 percent encoding and decoding of QStrings. -
91 -
92 Calling isRelative() will tell whether or not the URL is -
93 relative. A relative URL can be resolved by passing it as argument -
94 to resolved(), which returns an absolute URL. isParentOf() is used -
95 for determining whether one URL is a parent of another. -
96 -
97 fromLocalFile() constructs a QUrl by parsing a local -
98 file path. toLocalFile() converts a URL to a local file path. -
99 -
100 The human readable representation of the URL is fetched with -
101 toString(). This representation is appropriate for displaying a -
102 URL to a user in unencoded form. The encoded form however, as -
103 returned by toEncoded(), is for internal use, passing to web -
104 servers, mail clients and so on. -
105 -
106 QUrl conforms to the URI specification from -
107 \l{RFC 3986} (Uniform Resource Identifier: Generic Syntax), and includes -
108 scheme extensions from \l{RFC 1738} (Uniform Resource Locators). Case -
109 folding rules in QUrl conform to \l{RFC 3491} (Nameprep: A Stringprep -
110 Profile for Internationalized Domain Names (IDN)). -
111 -
112 \section2 Error checking -
113 -
114 QUrl is capable of detecting many errors in URLs while parsing it or when -
115 components of the URL are set with individual setter methods (like -
116 setScheme(), setHost() or setPath()). If the parsing or setter function is -
117 successful, any previously recorded error conditions will be discarded. -
118 -
119 By default, QUrl setter methods operate in QUrl::TolerantMode, which means -
120 they accept some common mistakes and mis-representation of data. An -
121 alternate method of parsing is QUrl::StrictMode, which applies further -
122 checks. See QUrl::ParsingMode for a description of the difference of the -
123 parsing modes. -
124 -
125 QUrl only checks for conformance with the URL specification. It does not -
126 try to verify that high-level protocol URLs are in the format they are -
127 expected to be by handlers elsewhere. For example, the following URIs are -
128 all considered valid by QUrl, even if they do not make sense when used: -
129 -
130 \list -
131 \li "http:/filename.html" -
132 \li "mailto://example.com" -
133 \endlist -
134 -
135 When the parser encounters an error, it signals the event by making -
136 isValid() return false and toString() / toEncoded() return an empty string. -
137 If it is necessary to show the user the reason why the URL failed to parse, -
138 the error condition can be obtained from QUrl by calling errorString(). -
139 Note that this message is highly technical and may not make sense to -
140 end-users. -
141 -
142 QUrl is capable of recording only one error condition. If more than one -
143 error is found, it is undefined which error is reported. -
144 -
145 \section2 Character Conversions -
146 -
147 Follow these rules to avoid erroneous character conversion when -
148 dealing with URLs and strings: -
149 -
150 \list -
151 \li When creating an QString to contain a URL from a QByteArray or a -
152 char*, always use QString::fromUtf8(). -
153 \endlist -
154*/ -
155 -
156/*! -
157 \enum QUrl::ParsingMode -
158 -
159 The parsing mode controls the way QUrl parses strings. -
160 -
161 \value TolerantMode QUrl will try to correct some common errors in URLs. -
162 This mode is useful for parsing URLs coming from sources -
163 not known to be strictly standards-conforming. -
164 -
165 \value StrictMode Only valid URLs are accepted. This mode is useful for -
166 general URL validation. -
167 -
168 \value DecodedMode QUrl will interpret the URL component in the fully-decoded form, -
169 where percent characters stand for themselves, not as the beginning -
170 of a percent-encoded sequence. This mode is only valid for the -
171 setters setting components of a URL; it is not permitted in -
172 the QUrl constructor, in fromEncoded() or in setUrl(). -
173 -
174 In TolerantMode, the parser has the following behaviour: -
175 -
176 \list -
177 -
178 \li Spaces and "%20": unencoded space characters will be accepted and will -
179 be treated as equivalent to "%20". -
180 -
181 \li Single "%" characters: Any occurrences of a percent character "%" not -
182 followed by exactly two hexadecimal characters (e.g., "13% coverage.html") -
183 will be replaced by "%25". Note that one lone "%" character will trigger -
184 the correction mode for all percent characters. -
185 -
186 \li Reserved and unreserved characters: An encoded URL should only -
187 contain a few characters as literals; all other characters should -
188 be percent-encoded. In TolerantMode, these characters will be -
189 automatically percent-encoded where they are not allowed: -
190 space / double-quote / "<" / ">" / "\" / -
191 "^" / "`" / "{" / "|" / "}" -
192 Those same characters can be decoded again by passing QUrl::DecodeReserved -
193 to toString() or toEncoded(). -
194 -
195 \endlist -
196 -
197 When in StrictMode, if a parsing error is found, isValid() will return \c -
198 false and errorString() will return a message describing the error. -
199 If more than one error is detected, it is undefined which error gets -
200 reported. -
201 -
202 Note that TolerantMode is not usually enough for parsing user input, which -
203 often contains more errors and expectations than the parser can deal with. -
204 When dealing with data coming directly from the user -- as opposed to data -
205 coming from data-transfer sources, such as other programs -- it is -
206 recommended to use fromUserInput(). -
207 -
208 \sa fromUserInput(), setUrl(), toString(), toEncoded(), QUrl::FormattingOptions -
209*/ -
210 -
211/*! -
212 \enum QUrl::UrlFormattingOption -
213 -
214 The formatting options define how the URL is formatted when written out -
215 as text. -
216 -
217 \value None The format of the URL is unchanged. -
218 \value RemoveScheme The scheme is removed from the URL. -
219 \value RemovePassword Any password in the URL is removed. -
220 \value RemoveUserInfo Any user information in the URL is removed. -
221 \value RemovePort Any specified port is removed from the URL. -
222 \value RemoveAuthority -
223 \value RemovePath The URL's path is removed, leaving only the scheme, -
224 host address, and port (if present). -
225 \value RemoveQuery The query part of the URL (following a '?' character) -
226 is removed. -
227 \value RemoveFragment -
228 \value PreferLocalFile If the URL is a local file according to isLocalFile() -
229 and contains no query or fragment, a local file path is returned. -
230 \value StripTrailingSlash The trailing slash is removed if one is present. -
231 -
232 Note that the case folding rules in \l{RFC 3491}{Nameprep}, which QUrl -
233 conforms to, require host names to always be converted to lower case, -
234 regardless of the Qt::FormattingOptions used. -
235 -
236 The options from QUrl::ComponentFormattingOptions are also possible. -
237 -
238 \sa QUrl::ComponentFormattingOptions -
239*/ -
240 -
241/*! -
242 \enum QUrl::ComponentFormattingOption -
243 \since 5.0 -
244 -
245 The component formatting options define how the components of an URL will -
246 be formatted when written out as text. They can be combined with the -
247 options from QUrl::FormattingOptions when used in toString() and -
248 toEncoded(). -
249 -
250 \value PrettyDecoded The component is returned in a "pretty form", with -
251 most percent-encoded characters decoded. The exact -
252 behavior of PrettyDecoded varies from component to -
253 component and may also change from Qt release to Qt -
254 release. This is the default. -
255 -
256 \value EncodeSpaces Leave space characters in their encoded form ("%20"). -
257 -
258 \value EncodeUnicode Leave non-US-ASCII characters encoded in their UTF-8 -
259 percent-encoded form (e.g., "%C3%A9" for the U+00E9 -
260 codepoint, LATIN SMALL LETTER E WITH ACUTE). -
261 -
262 \value EncodeDelimiters Leave certain delimiters in their encoded form, as -
263 would appear in the URL when the full URL is -
264 represented as text. The delimiters are affected -
265 by this option change from component to component. -
266 -
267 \value EncodeReserved Leave the US-ASCII reserved characters in their encoded -
268 forms. -
269 -
270 \value DecodeReserved Decode the US-ASCII reserved characters. -
271 -
272 \value FullyEncoded Leave all characters in their properly-encoded form, -
273 as this component would appear as part of a URL. When -
274 used with toString(), this produces a fully-compliant -
275 URL in QString form, exactly equal to the result of -
276 toEncoded() -
277 -
278 \value FullyDecoded Attempt to decode as much as possible. For individual -
279 components of the URL, this decodes every percent -
280 encoding sequence, including control characters (U+0000 -
281 to U+001F) and UTF-8 sequences found in percent-encoded form. -
282 Note: if the component contains non-US-ASCII sequences -
283 that aren't valid UTF-8 sequences, the behaviour is -
284 undefined since QString cannot represent those values -
285 (data will be lost!) -
286 This mode is should not be used in functions where more -
287 than one URL component is returned (userInfo() and authority()) -
288 and it is not allowed in url() and toString(). -
289 -
290 The values of EncodeReserved and DecodeReserved should not be used together -
291 in one call. The behaviour is undefined if that happens. They are provided -
292 as separate values because the behaviour of the "pretty mode" with regards -
293 to reserved characters is different on certain components and specially on -
294 the full URL. -
295 -
296 The FullyDecoded mode is similar to the behaviour of the functions -
297 returning QString in Qt 4.x, including the fact that they will most likely -
298 cause data loss if the component in question contains a non-UTF-8 -
299 percent-encoded sequence. Fortunately, those cases aren't common, so this -
300 mode should be used when the component in question is used in a non-URL -
301 context. For example, in an FTP client application, the path to the remote -
302 file could be stored in a QUrl object, and the string to be transmitted to -
303 the FTP server should be obtained using this flag. -
304 -
305 \sa QUrl::FormattingOptions -
306*/ -
307 -
308#include "qurl.h" -
309#include "qurl_p.h" -
310#include "qplatformdefs.h" -
311#include "qstring.h" -
312#include "qstringlist.h" -
313#include "qdebug.h" -
314#include "qhash.h" -
315#include "qdir.h" // for QDir::fromNativeSeparators -
316#include "qtldurl_p.h" -
317#include "private/qipaddress_p.h" -
318#include "qurlquery.h" -
319#if defined(Q_OS_WINCE_WM) -
320#pragma optimize("g", off) -
321#endif -
322 -
323QT_BEGIN_NAMESPACE -
324 -
325inline static bool isHex(char c) -
326{ -
327 c |= 0x20;
executed (the execution status of this line is deduced): c |= 0x20;
-
328 return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
executed: return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
Execution Count:43
43
329} -
330 -
331static inline QString ftpScheme() -
332{ -
333 return QStringLiteral("ftp");
executed: return QString::fromUtf8("" "ftp" "", sizeof("ftp") - 1);
Execution Count:44
44
334} -
335 -
336static inline QString httpScheme() -
337{ -
338 return QStringLiteral("http");
never executed: return QString::fromUtf8("" "http" "", sizeof("http") - 1);
0
339} -
340 -
341static inline QString fileScheme() -
342{ -
343 return QStringLiteral("file");
executed: return QString::fromUtf8("" "file" "", sizeof("file") - 1);
Execution Count:12165
12165
344} -
345 -
346class QUrlPrivate -
347{ -
348public: -
349 enum Section { -
350 Scheme = 0x01, -
351 UserName = 0x02, -
352 Password = 0x04, -
353 UserInfo = UserName | Password, -
354 Host = 0x08, -
355 Port = 0x10, -
356 Authority = UserInfo | Host | Port, -
357 Path = 0x20, -
358 Hierarchy = Authority | Path, -
359 Query = 0x40, -
360 Fragment = 0x80, -
361 FullUrl = 0xff -
362 }; -
363 -
364 enum ErrorCode { -
365 // the high byte of the error code matches the Section -
366 // the first item in each value must be the generic "Invalid xxx Error" -
367 InvalidSchemeError = Scheme << 8, -
368 -
369 InvalidUserNameError = UserName << 8, -
370 -
371 InvalidPasswordError = Password << 8, -
372 -
373 InvalidRegNameError = Host << 8, -
374 InvalidIPv4AddressError, -
375 InvalidIPv6AddressError, -
376 InvalidIPvFutureError, -
377 HostMissingEndBracket, -
378 -
379 InvalidPortError = Port << 8, -
380 PortEmptyError, -
381 -
382 InvalidPathError = Path << 8, -
383 -
384 InvalidQueryError = Query << 8, -
385 -
386 InvalidFragmentError = Fragment << 8, -
387 -
388 // the following two cases are only possible in combination -
389 // with presence/absence of the authority and scheme. See validityError(). -
390 AuthorityPresentAndPathIsRelative = Authority << 8 | Path << 8 | 0x10000, -
391 RelativeUrlPathContainsColonBeforeSlash = Scheme << 8 | Authority << 8 | Path << 8 | 0x10000, -
392 -
393 NoError = 0 -
394 }; -
395 -
396 struct Error { -
397 QString source; -
398 ErrorCode code; -
399 int position; -
400 }; -
401 -
402 QUrlPrivate(); -
403 QUrlPrivate(const QUrlPrivate &copy); -
404 ~QUrlPrivate(); -
405 -
406 void parse(const QString &url, QUrl::ParsingMode parsingMode); -
407 bool isEmpty() const -
408 { return sectionIsPresent == 0 && port == -1 && path.isEmpty(); }
executed: return sectionIsPresent == 0 && port == -1 && path.isEmpty();
Execution Count:11381
11381
409 -
410 Error *cloneError() const; -
411 void clearError(); -
412 void setError(ErrorCode errorCode, const QString &source, int supplement = -1); -
413 ErrorCode validityError(QString *source = 0, int *position = 0) const; -
414 bool validateComponent(Section section, const QString &input, int begin, int end); -
415 bool validateComponent(Section section, const QString &input) -
416 { return validateComponent(section, input, 0, uint(input.length())); }
executed: return validateComponent(section, input, 0, uint(input.length()));
Execution Count:21
21
417 -
418 // no QString scheme() const; -
419 void appendAuthority(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const; -
420 void appendUserInfo(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const; -
421 void appendUserName(QString &appendTo, QUrl::FormattingOptions options) const; -
422 void appendPassword(QString &appendTo, QUrl::FormattingOptions options) const; -
423 void appendHost(QString &appendTo, QUrl::FormattingOptions options) const; -
424 void appendPath(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const; -
425 void appendQuery(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const; -
426 void appendFragment(QString &appendTo, QUrl::FormattingOptions options) const; -
427 -
428 // the "end" parameters are like STL iterators: they point to one past the last valid element -
429 bool setScheme(const QString &value, int len, bool doSetError); -
430 void setAuthority(const QString &auth, int from, int end, QUrl::ParsingMode mode); -
431 void setUserInfo(const QString &userInfo, int from, int end); -
432 void setUserName(const QString &value, int from, int end); -
433 void setPassword(const QString &value, int from, int end); -
434 bool setHost(const QString &value, int from, int end, QUrl::ParsingMode mode); -
435 void setPath(const QString &value, int from, int end); -
436 void setQuery(const QString &value, int from, int end); -
437 void setFragment(const QString &value, int from, int end); -
438 -
439 inline bool hasScheme() const { return sectionIsPresent & Scheme; }
executed: return sectionIsPresent & Scheme;
Execution Count:9840
9840
440 inline bool hasAuthority() const { return sectionIsPresent & Authority; }
executed: return sectionIsPresent & Authority;
Execution Count:9628
9628
441 inline bool hasUserInfo() const { return sectionIsPresent & UserInfo; }
executed: return sectionIsPresent & UserInfo;
Execution Count:4613
4613
442 inline bool hasUserName() const { return sectionIsPresent & UserName; }
executed: return sectionIsPresent & UserName;
Execution Count:3590
3590
443 inline bool hasPassword() const { return sectionIsPresent & Password; }
executed: return sectionIsPresent & Password;
Execution Count:3394
3394
444 inline bool hasHost() const { return sectionIsPresent & Host; }
never executed: return sectionIsPresent & Host;
0
445 inline bool hasPort() const { return port != -1; }
never executed: return port != -1;
0
446 inline bool hasPath() const { return !path.isEmpty(); }
never executed: return !path.isEmpty();
0
447 inline bool hasQuery() const { return sectionIsPresent & Query; }
executed: return sectionIsPresent & Query;
Execution Count:8480
8480
448 inline bool hasFragment() const { return sectionIsPresent & Fragment; }
executed: return sectionIsPresent & Fragment;
Execution Count:9156
9156
449 -
450 QString mergePaths(const QString &relativePath) const; -
451 -
452 QAtomicInt ref; -
453 int port; -
454 -
455 QString scheme; -
456 QString userName; -
457 QString password; -
458 QString host; -
459 QString path; -
460 QString query; -
461 QString fragment; -
462 -
463 Error *error; -
464 -
465 // not used for: -
466 // - Port (port == -1 means absence) -
467 // - Path (there's no path delimiter, so we optimize its use out of existence) -
468 // Schemes are never supposed to be empty, but we keep the flag anyway -
469 uchar sectionIsPresent; -
470}; -
471 -
472inline QUrlPrivate::QUrlPrivate() -
473 : ref(1), port(-1), -
474 error(0), -
475 sectionIsPresent(0) -
476{ -
477}
executed: }
Execution Count:14664
14664
478 -
479inline QUrlPrivate::QUrlPrivate(const QUrlPrivate &copy) -
480 : ref(1), port(copy.port), -
481 scheme(copy.scheme), -
482 userName(copy.userName), -
483 password(copy.password), -
484 host(copy.host), -
485 path(copy.path), -
486 query(copy.query), -
487 fragment(copy.fragment), -
488 error(copy.cloneError()), -
489 sectionIsPresent(copy.sectionIsPresent) -
490{ -
491}
executed: }
Execution Count:8150
8150
492 -
493inline QUrlPrivate::~QUrlPrivate() -
494{ -
495 delete error;
executed (the execution status of this line is deduced): delete error;
-
496}
executed: }
Execution Count:22811
22811
497 -
498inline QUrlPrivate::Error *QUrlPrivate::cloneError() const -
499{ -
500 return error ? new Error(*error) : 0;
executed: return error ? new Error(*error) : 0;
Execution Count:8149
8149
501} -
502 -
503inline void QUrlPrivate::clearError() -
504{ -
505 delete error;
executed (the execution status of this line is deduced): delete error;
-
506 error = 0;
executed (the execution status of this line is deduced): error = 0;
-
507}
executed: }
Execution Count:24961
24961
508 -
509inline void QUrlPrivate::setError(ErrorCode errorCode, const QString &source, int supplement) -
510{ -
511 if (error) {
evaluated: error
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:122
19-122
512 // don't overwrite an error set in a previous section during parsing -
513 return;
executed: return;
Execution Count:19
19
514 } -
515 error = new Error;
executed (the execution status of this line is deduced): error = new Error;
-
516 error->code = errorCode;
executed (the execution status of this line is deduced): error->code = errorCode;
-
517 error->source = source;
executed (the execution status of this line is deduced): error->source = source;
-
518 error->position = supplement;
executed (the execution status of this line is deduced): error->position = supplement;
-
519}
executed: }
Execution Count:122
122
520 -
521// From RFC 3896, Appendix A Collected ABNF for URI -
522// URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] -
523//[...] -
524// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) -
525// -
526// authority = [ userinfo "@" ] host [ ":" port ] -
527// userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) -
528// host = IP-literal / IPv4address / reg-name -
529// port = *DIGIT -
530//[...] -
531// reg-name = *( unreserved / pct-encoded / sub-delims ) -
532//[..] -
533// pchar = unreserved / pct-encoded / sub-delims / ":" / "@" -
534// -
535// query = *( pchar / "/" / "?" ) -
536// -
537// fragment = *( pchar / "/" / "?" ) -
538// -
539// pct-encoded = "%" HEXDIG HEXDIG -
540// -
541// unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" -
542// reserved = gen-delims / sub-delims -
543// gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" -
544// sub-delims = "!" / "$" / "&" / "'" / "(" / ")" -
545// / "*" / "+" / "," / ";" / "=" -
546// the path component has a complex ABNF that basically boils down to -
547// slash-separated segments of "pchar" -
548 -
549// The above is the strict definition of the URL components and it is what we -
550// return encoded as FullyEncoded. However, we store the equivalent to -
551// PrettyDecoded internally, as that is the default formatting mode and most -
552// likely to be used. PrettyDecoded decodes spaces, unicode sequences and -
553// unambiguous delimiters. -
554// -
555// An ambiguous delimiter is a delimiter that, if appeared decoded, would be -
556// interpreted as the beginning of a new component. The exact delimiters that -
557// match that definition change according to the use. When each field is -
558// considered in isolation from the rest, there are no ambiguities. In other -
559// words, we always store the most decoded form (except for the query, see -
560// below). -
561// -
562// The ambiguities arise when components are put together. From last to first -
563// component of a full URL, the ambiguities are: -
564// - fragment: none, since it's the last. -
565// - query: the "#" character is ambiguous, as it starts the fragment. In -
566// addition, the "+" character is treated specially, as should be both -
567// intra-query delimiters. Since we don't know which ones they are, we -
568// keep all reserved characters untouched. -
569// - path: the "#" and "?" characters are ambigous. In addition to them, -
570// the slash itself is considered special. -
571// - host: completely special but never ambiguous, see setHost() below. -
572// - password: the "#", "?", "/", "[", "]" and "@" characters are ambiguous -
573// - username: the "#", "?", "/", "[", "]", "@", and ":" characters are ambiguous -
574// - scheme: doesn't accept any delimiter, see setScheme() below. -
575// -
576// When the authority component is considered in isolation, the ambiguities of -
577// its components are: -
578// - host: special, never ambiguous -
579// - password: "[", "]", "@" are ambiguous -
580// - username: "[", "]", "@", ":" are ambiguous -
581// -
582// Finally, when the userinfo is considered in isolation, the ambiguities of its -
583// components are: -
584// - password: none, since it's the last -
585// - username: ":" is ambiguous -
586 -
587// list the recoding table modifications to be used with the recodeFromUser and -
588// appendToUser functions, according to the rules above. -
589// the encodedXXX tables are run with the delimiters set to "leave" by default; -
590// the decodedXXX tables are run with the delimiters set to "decode" by default -
591// (except for the query, which doesn't use these functions) -
592 -
593#define decode(x) ushort(x) -
594#define leave(x) ushort(0x100 | (x)) -
595#define encode(x) ushort(0x200 | (x)) -
596 -
597static const ushort encodedUserNameActions[] = { -
598 // first field, everything must be encoded, including the ":" -
599 // userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) -
600 encode('/'), // 0 -
601 encode('?'), // 1 -
602 encode('#'), // 2 -
603 encode('['), // 3 -
604 encode(']'), // 4 -
605 encode('@'), // 5 -
606 encode(':'), // 6 -
607 0 -
608}; -
609static const ushort * const decodedUserNameInAuthorityActions = encodedUserNameActions + 3; -
610static const ushort * const decodedUserNameInUserInfoActions = encodedUserNameActions + 6; -
611static const ushort * const decodedUserNameInUrlActions = encodedUserNameActions; -
612static const ushort * const decodedUserNameInIsolationActions = 0; -
613 -
614static const ushort encodedPasswordActions[] = { -
615 // same as encodedUserNameActions, but decode ":" -
616 // userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) -
617 encode('/'), // 0 -
618 encode('?'), // 1 -
619 encode('#'), // 2 -
620 encode('['), // 3 -
621 encode(']'), // 4 -
622 encode('@'), // 5 -
623 0 -
624}; -
625static const ushort * const decodedPasswordInAuthorityActions = encodedPasswordActions + 3; -
626static const ushort * const decodedPasswordInUserInfoActions = 0; -
627static const ushort * const decodedPasswordInUrlActions = encodedPasswordActions; -
628static const ushort * const decodedPasswordInIsolationActions = 0; -
629 -
630static const ushort encodedPathActions[] = { -
631 // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" -
632 encode('['), // 0 -
633 encode(']'), // 1 -
634 encode('?'), // 2 -
635 encode('#'), // 3 -
636 leave('/'), // 4 -
637 0 -
638}; -
639static const ushort decodedPathInUrlActions[] = { -
640 decode('{'), // 0 -
641 decode('}'), // 1 -
642 encode('?'), // 2 -
643 encode('#'), // 3 -
644 leave('/'), // 4 -
645 0 -
646}; -
647static const ushort * const decodedPathInIsolationActions = encodedPathActions + 4; // leave('/') -
648 -
649static const ushort encodedFragmentActions[] = { -
650 // fragment = *( pchar / "/" / "?" ) -
651 // gen-delims permitted: ":" / "@" / "/" / "?" -
652 // -> must encode: "[" / "]" / "#" -
653 // HOWEVER: we allow "#" to remain decoded -
654 decode('#'), // 0 -
655 decode(':'), // 1 -
656 decode('@'), // 2 -
657 decode('/'), // 3 -
658 decode('?'), // 4 -
659 encode('['), // 5 -
660 encode(']'), // 6 -
661 0 -
662}; -
663static const ushort * const decodedFragmentInUrlActions = 0; -
664static const ushort * const decodedFragmentInIsolationActions = 0; -
665 -
666// the query is handled specially: the decodedQueryXXX tables are run with -
667// the delimiters set to "leave" by default and the others set to "encode" -
668static const ushort encodedQueryActions[] = { -
669 // query = *( pchar / "/" / "?" ) -
670 // gen-delims permitted: ":" / "@" / "/" / "?" -
671 // HOWEVER: we leave alone them alone, plus "[" and "]" -
672 // -> must encode: "#" -
673 encode('#'), // 0 -
674 0 -
675}; -
676static const ushort decodedQueryInIsolationActions[] = { -
677 decode('"'), // 0 -
678 decode('<'), // 1 -
679 decode('>'), // 2 -
680 decode('^'), // 3 -
681 decode('\\'),// 4 -
682 decode('|'), // 5 -
683 decode('{'), // 6 -
684 decode('}'), // 7 -
685 decode('#'), // 8 -
686 0 -
687}; -
688static const ushort decodedQueryInUrlActions[] = { -
689 decode('{'), // 6 -
690 decode('}'), // 7 -
691 encode('#'), // 8 -
692 0 -
693}; -
694 -
695static inline void parseDecodedComponent(QString &data) -
696{ -
697 data.replace(QLatin1Char('%'), QStringLiteral("%25"));
executed (the execution status of this line is deduced): data.replace(QLatin1Char('%'), QString::fromUtf8("" "%25" "", sizeof("%25") - 1));
-
698}
executed: }
Execution Count:2047
2047
699 -
700static inline QString -
701recodeFromUser(const QString &input, const ushort *actions, int from, int to) -
702{ -
703 QString output;
executed (the execution status of this line is deduced): QString output;
-
704 const QChar *begin = input.constData() + from;
executed (the execution status of this line is deduced): const QChar *begin = input.constData() + from;
-
705 const QChar *end = input.constData() + to;
executed (the execution status of this line is deduced): const QChar *end = input.constData() + to;
-
706 if (qt_urlRecode(output, begin, end,
evaluated: qt_urlRecode(output, begin, end, QUrl::DecodeReserved, actions)
TRUEFALSE
yes
Evaluation Count:159
yes
Evaluation Count:13778
159-13778
707 QUrl::DecodeReserved, actions))
evaluated: qt_urlRecode(output, begin, end, QUrl::DecodeReserved, actions)
TRUEFALSE
yes
Evaluation Count:159
yes
Evaluation Count:13778
159-13778
708 return output;
executed: return output;
Execution Count:159
159
709 -
710 return input.mid(from, to - from);
executed: return input.mid(from, to - from);
Execution Count:13777
13777
711} -
712 -
713// appendXXXX functions: -
714// the internal value is stored in its most decoded form, so that case is easy. -
715// DecodeUnicode and DecodeSpaces are handled by qt_urlRecode. -
716// That leaves these functions to handle two cases related to delimiters: -
717// 1) encoded encodedXXXX tables -
718// 2) decoded decodedXXXX tables -
719static inline void appendToUser(QString &appendTo, const QString &value, QUrl::FormattingOptions options, -
720 const ushort *encodedActions, const ushort *decodedActions) -
721{ -
722 if (options == QUrl::PrettyDecoded) {
evaluated: options == QUrl::PrettyDecoded
TRUEFALSE
yes
Evaluation Count:3821
yes
Evaluation Count:10540
3821-10540
723 appendTo += value;
executed (the execution status of this line is deduced): appendTo += value;
-
724 return;
executed: return;
Execution Count:3821
3821
725 } -
726 -
727 const ushort *actions = 0;
executed (the execution status of this line is deduced): const ushort *actions = 0;
-
728 if (options & QUrl::EncodeDelimiters)
evaluated: options & QUrl::EncodeDelimiters
TRUEFALSE
yes
Evaluation Count:10402
yes
Evaluation Count:138
138-10402
729 actions = encodedActions;
executed: actions = encodedActions;
Execution Count:10402
10402
730 else -
731 actions = decodedActions;
executed: actions = decodedActions;
Execution Count:138
138
732 -
733 if (!qt_urlRecode(appendTo, value.constData(), value.constEnd(), options, actions))
evaluated: !qt_urlRecode(appendTo, value.constData(), value.constEnd(), options, actions)
TRUEFALSE
yes
Evaluation Count:9725
yes
Evaluation Count:815
815-9725
734 appendTo += value;
executed: appendTo += value;
Execution Count:9725
9725
735}
executed: }
Execution Count:10540
10540
736 -
737inline void QUrlPrivate::appendAuthority(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const -
738{ -
739 if ((options & QUrl::RemoveUserInfo) != QUrl::RemoveUserInfo) {
evaluated: (options & QUrl::RemoveUserInfo) != QUrl::RemoveUserInfo
TRUEFALSE
yes
Evaluation Count:3588
yes
Evaluation Count:801
801-3588
740 appendUserInfo(appendTo, options, appendingTo);
executed (the execution status of this line is deduced): appendUserInfo(appendTo, options, appendingTo);
-
741 -
742 // add '@' only if we added anything -
743 if (hasUserName() || (hasPassword() && (options & QUrl::RemovePassword) == 0))
evaluated: hasUserName()
TRUEFALSE
yes
Evaluation Count:553
yes
Evaluation Count:3038
evaluated: hasPassword()
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:2944
evaluated: (options & QUrl::RemovePassword) == 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:91
5-3038
744 appendTo += QLatin1Char('@');
executed: appendTo += QLatin1Char('@');
Execution Count:558
558
745 }
executed: }
Execution Count:3593
3593
746 appendHost(appendTo, options);
executed (the execution status of this line is deduced): appendHost(appendTo, options);
-
747 if (!(options & QUrl::RemovePort) && port != -1)
evaluated: !(options & QUrl::RemovePort)
TRUEFALSE
yes
Evaluation Count:4389
yes
Evaluation Count:4
evaluated: port != -1
TRUEFALSE
yes
Evaluation Count:1304
yes
Evaluation Count:3082
4-4389
748 appendTo += QLatin1Char(':') + QString::number(port);
executed: appendTo += QLatin1Char(':') + QString::number(port);
Execution Count:1304
1304
749}
executed: }
Execution Count:4389
4389
750 -
751inline void QUrlPrivate::appendUserInfo(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const -
752{ -
753 if (Q_LIKELY(!hasUserInfo()))
evaluated: __builtin_expect(!!(!hasUserInfo()), true)
TRUEFALSE
yes
Evaluation Count:3903
yes
Evaluation Count:712
712-3903
754 return;
executed: return;
Execution Count:3902
3902
755 -
756 const ushort *userNameActions;
executed (the execution status of this line is deduced): const ushort *userNameActions;
-
757 const ushort *passwordActions;
executed (the execution status of this line is deduced): const ushort *passwordActions;
-
758 if (options & QUrl::EncodeDelimiters) {
evaluated: options & QUrl::EncodeDelimiters
TRUEFALSE
yes
Evaluation Count:574
yes
Evaluation Count:138
138-574
759 userNameActions = encodedUserNameActions;
executed (the execution status of this line is deduced): userNameActions = encodedUserNameActions;
-
760 passwordActions = encodedPasswordActions;
executed (the execution status of this line is deduced): passwordActions = encodedPasswordActions;
-
761 } else {
executed: }
Execution Count:574
574
762 switch (appendingTo) { -
763 case UserInfo: -
764 userNameActions = decodedUserNameInUserInfoActions;
executed (the execution status of this line is deduced): userNameActions = decodedUserNameInUserInfoActions;
-
765 passwordActions = decodedPasswordInUserInfoActions;
executed (the execution status of this line is deduced): passwordActions = decodedPasswordInUserInfoActions;
-
766 break;
executed: break;
Execution Count:54
54
767 -
768 case Authority: -
769 userNameActions = decodedUserNameInAuthorityActions;
executed (the execution status of this line is deduced): userNameActions = decodedUserNameInAuthorityActions;
-
770 passwordActions = decodedPasswordInAuthorityActions;
executed (the execution status of this line is deduced): passwordActions = decodedPasswordInAuthorityActions;
-
771 break;
executed: break;
Execution Count:23
23
772 -
773 case FullUrl: -
774 default: -
775 userNameActions = decodedUserNameInUrlActions;
executed (the execution status of this line is deduced): userNameActions = decodedUserNameInUrlActions;
-
776 passwordActions = decodedPasswordInUrlActions;
executed (the execution status of this line is deduced): passwordActions = decodedPasswordInUrlActions;
-
777 break;
executed: break;
Execution Count:61
61
778 } -
779 }
executed: }
Execution Count:138
138
780 -
781 if ((options & QUrl::EncodeReserved) == 0)
evaluated: (options & QUrl::EncodeReserved) == 0
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:625
87-625
782 options |= QUrl::DecodeReserved;
executed: options |= QUrl::DecodeReserved;
Execution Count:87
87
783 -
784 if (!qt_urlRecode(appendTo, userName.constData(), userName.constEnd(), options, userNameActions))
evaluated: !qt_urlRecode(appendTo, userName.constData(), userName.constEnd(), options, userNameActions)
TRUEFALSE
yes
Evaluation Count:652
yes
Evaluation Count:60
60-652
785 appendTo += userName;
executed: appendTo += userName;
Execution Count:652
652
786 if (options & QUrl::RemovePassword || !hasPassword()) {
evaluated: options & QUrl::RemovePassword
TRUEFALSE
yes
Evaluation Count:357
yes
Evaluation Count:355
evaluated: !hasPassword()
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:195
160-357
787 return;
executed: return;
Execution Count:517
517
788 } else { -
789 appendTo += QLatin1Char(':');
executed (the execution status of this line is deduced): appendTo += QLatin1Char(':');
-
790 if (!qt_urlRecode(appendTo, password.constData(), password.constEnd(), options, passwordActions))
evaluated: !qt_urlRecode(appendTo, password.constData(), password.constEnd(), options, passwordActions)
TRUEFALSE
yes
Evaluation Count:141
yes
Evaluation Count:54
54-141
791 appendTo += password;
executed: appendTo += password;
Execution Count:141
141
792 }
executed: }
Execution Count:195
195
793} -
794 -
795inline void QUrlPrivate::appendUserName(QString &appendTo, QUrl::FormattingOptions options) const -
796{ -
797 appendToUser(appendTo, userName, options, encodedUserNameActions, decodedUserNameInIsolationActions);
executed (the execution status of this line is deduced): appendToUser(appendTo, userName, options, encodedUserNameActions, decodedUserNameInIsolationActions);
-
798}
executed: }
Execution Count:752
752
799 -
800inline void QUrlPrivate::appendPassword(QString &appendTo, QUrl::FormattingOptions options) const -
801{ -
802 appendToUser(appendTo, password, options, encodedPasswordActions, decodedPasswordInIsolationActions);
executed (the execution status of this line is deduced): appendToUser(appendTo, password, options, encodedPasswordActions, decodedPasswordInIsolationActions);
-
803}
executed: }
Execution Count:239
239
804 -
805inline void QUrlPrivate::appendPath(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const -
806{ -
807 if (appendingTo != Path && !(options & QUrl::EncodeDelimiters)) {
evaluated: appendingTo != Path
TRUEFALSE
yes
Evaluation Count:4780
yes
Evaluation Count:9172
evaluated: !(options & QUrl::EncodeDelimiters)
TRUEFALSE
yes
Evaluation Count:1477
yes
Evaluation Count:3303
1477-9172
808 if (!qt_urlRecode(appendTo, path.constData(), path.constEnd(), options, decodedPathInUrlActions))
evaluated: !qt_urlRecode(appendTo, path.constData(), path.constEnd(), options, decodedPathInUrlActions)
TRUEFALSE
yes
Evaluation Count:1459
yes
Evaluation Count:15
15-1459
809 appendTo += path;
executed: appendTo += path;
Execution Count:1459
1459
810 -
811 } else {
executed: }
Execution Count:1479
1479
812 appendToUser(appendTo, path, options, encodedPathActions, decodedPathInIsolationActions);
executed (the execution status of this line is deduced): appendToUser(appendTo, path, options, encodedPathActions, decodedPathInIsolationActions);
-
813 }
executed: }
Execution Count:12475
12475
814} -
815 -
816inline void QUrlPrivate::appendFragment(QString &appendTo, QUrl::FormattingOptions options) const -
817{ -
818 appendToUser(appendTo, fragment, options, encodedFragmentActions, decodedFragmentInIsolationActions);
executed (the execution status of this line is deduced): appendToUser(appendTo, fragment, options, encodedFragmentActions, decodedFragmentInIsolationActions);
-
819}
executed: }
Execution Count:895
895
820 -
821inline void QUrlPrivate::appendQuery(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const -
822{ -
823 // almost the same code as the previous functions -
824 // except we prefer not to touch the delimiters -
825 if (options == QUrl::PrettyDecoded && appendingTo == Query) {
evaluated: options == QUrl::PrettyDecoded
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:447
partially evaluated: appendingTo == Query
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-447
826 appendTo += query;
executed (the execution status of this line is deduced): appendTo += query;
-
827 return;
executed: return;
Execution Count:34
34
828 } -
829 -
830 const ushort *actions = 0;
executed (the execution status of this line is deduced): const ushort *actions = 0;
-
831 if (options & QUrl::EncodeDelimiters) {
evaluated: options & QUrl::EncodeDelimiters
TRUEFALSE
yes
Evaluation Count:355
yes
Evaluation Count:92
92-355
832 actions = encodedQueryActions;
executed (the execution status of this line is deduced): actions = encodedQueryActions;
-
833 } else {
executed: }
Execution Count:355
355
834 // reset to default qt_urlRecode behaviour (leave delimiters alone) -
835 options |= QUrl::EncodeDelimiters;
executed (the execution status of this line is deduced): options |= QUrl::EncodeDelimiters;
-
836 actions = appendingTo == Query ? decodedQueryInIsolationActions : decodedQueryInUrlActions;
evaluated: appendingTo == Query
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:74
18-74
837 }
executed: }
Execution Count:92
92
838 -
839 if (!qt_urlRecode(appendTo, query.constData(), query.constData() + query.length(),
evaluated: !qt_urlRecode(appendTo, query.constData(), query.constData() + query.length(), options, actions)
TRUEFALSE
yes
Evaluation Count:346
yes
Evaluation Count:101
101-346
840 options, actions))
evaluated: !qt_urlRecode(appendTo, query.constData(), query.constData() + query.length(), options, actions)
TRUEFALSE
yes
Evaluation Count:346
yes
Evaluation Count:101
101-346
841 appendTo += query;
executed: appendTo += query;
Execution Count:346
346
842}
executed: }
Execution Count:447
447
843 -
844// setXXX functions -
845 -
846inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetError) -
847{ -
848 // schemes are strictly RFC-compliant: -
849 // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) -
850 // we also lowercase the scheme -
851 -
852 // schemes in URLs are not allowed to be empty, but they can be in -
853 // "Relative URIs" which QUrl also supports. QUrl::setScheme does -
854 // not call us with len == 0, so this can only be from parse() -
855 scheme.clear();
executed (the execution status of this line is deduced): scheme.clear();
-
856 if (len == 0)
evaluated: len == 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6657
5-6657
857 return false;
executed: return false;
Execution Count:5
5
858 -
859 sectionIsPresent |= Scheme;
executed (the execution status of this line is deduced): sectionIsPresent |= Scheme;
-
860 -
861 // validate it: -
862 int needsLowercasing = -1;
executed (the execution status of this line is deduced): int needsLowercasing = -1;
-
863 const ushort *p = reinterpret_cast<const ushort *>(value.constData());
executed (the execution status of this line is deduced): const ushort *p = reinterpret_cast<const ushort *>(value.constData());
-
864 for (int i = 0; i < len; ++i) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:28624
yes
Evaluation Count:6628
6628-28624
865 if (p[i] >= 'a' && p[i] <= 'z')
evaluated: p[i] >= 'a'
TRUEFALSE
yes
Evaluation Count:28138
yes
Evaluation Count:494
partially evaluated: p[i] <= 'z'
TRUEFALSE
yes
Evaluation Count:28140
no
Evaluation Count:0
0-28140
866 continue;
executed: continue;
Execution Count:28139
28139
867 if (p[i] >= 'A' && p[i] <= 'Z') {
evaluated: p[i] >= 'A'
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:477
partially evaluated: p[i] <= 'Z'
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-477
868 needsLowercasing = i;
executed (the execution status of this line is deduced): needsLowercasing = i;
-
869 continue;
executed: continue;
Execution Count:17
17
870 } -
871 if (p[i] >= '0' && p[i] <= '9' && i > 0)
evaluated: p[i] >= '0'
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:348
evaluated: p[i] <= '9'
TRUEFALSE
yes
Evaluation Count:128
yes
Evaluation Count:1
evaluated: i > 0
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:4
1-348
872 continue;
executed: continue;
Execution Count:124
124
873 if (p[i] == '+' || p[i] == '-' || p[i] == '.')
partially evaluated: p[i] == '+'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:353
evaluated: p[i] == '-'
TRUEFALSE
yes
Evaluation Count:318
yes
Evaluation Count:35
evaluated: p[i] == '.'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:33
0-353
874 continue;
executed: continue;
Execution Count:320
320
875 -
876 // found something else -
877 // don't call setError needlessly: -
878 // if we've been called from parse(), it will try to recover -
879 if (doSetError)
evaluated: doSetError
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:27
6-27
880 setError(InvalidSchemeError, value, i);
executed: setError(InvalidSchemeError, value, i);
Execution Count:6
6
881 return false;
executed: return false;
Execution Count:33
33
882 } -
883 -
884 scheme = value.left(len);
executed (the execution status of this line is deduced): scheme = value.left(len);
-
885 -
886 if (needsLowercasing != -1) {
evaluated: needsLowercasing != -1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6621
4-6621
887 // schemes are ASCII only, so we don't need the full Unicode toLower -
888 QChar *schemeData = scheme.data(); // force detaching here
executed (the execution status of this line is deduced): QChar *schemeData = scheme.data();
-
889 for (int i = needsLowercasing; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:4
4-19
890 register ushort c = schemeData[i].unicode();
executed (the execution status of this line is deduced): register ushort c = schemeData[i].unicode();
-
891 if (c >= 'A' && c <= 'Z')
partially evaluated: c >= 'A'
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
evaluated: c <= 'Z'
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2
0-19
892 schemeData[i] = c + 0x20;
executed: schemeData[i] = c + 0x20;
Execution Count:17
17
893 }
executed: }
Execution Count:19
19
894 }
executed: }
Execution Count:4
4
895 return true;
executed: return true;
Execution Count:6619
6619
896} -
897 -
898inline void QUrlPrivate::setAuthority(const QString &auth, int from, int end, QUrl::ParsingMode mode) -
899{ -
900 sectionIsPresent &= ~Authority;
executed (the execution status of this line is deduced): sectionIsPresent &= ~Authority;
-
901 sectionIsPresent |= Host;
executed (the execution status of this line is deduced): sectionIsPresent |= Host;
-
902 -
903 // we never actually _loop_ -
904 while (from != end) {
evaluated: from != end
TRUEFALSE
yes
Evaluation Count:3884
yes
Evaluation Count:148
148-3884
905 int userInfoIndex = auth.indexOf(QLatin1Char('@'), from);
executed (the execution status of this line is deduced): int userInfoIndex = auth.indexOf(QLatin1Char('@'), from);
-
906 if (uint(userInfoIndex) < uint(end)) {
evaluated: uint(userInfoIndex) < uint(end)
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:3738
136-3738
907 setUserInfo(auth, from, userInfoIndex);
executed (the execution status of this line is deduced): setUserInfo(auth, from, userInfoIndex);
-
908 if (mode == QUrl::StrictMode && !validateComponent(UserInfo, auth, from, userInfoIndex))
evaluated: mode == QUrl::StrictMode
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:128
evaluated: !validateComponent(UserInfo, auth, from, userInfoIndex)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
1-128
909 break;
executed: break;
Execution Count:7
7
910 from = userInfoIndex + 1;
executed (the execution status of this line is deduced): from = userInfoIndex + 1;
-
911 }
executed: }
Execution Count:129
129
912 -
913 int colonIndex = auth.lastIndexOf(QLatin1Char(':'), end - 1);
executed (the execution status of this line is deduced): int colonIndex = auth.lastIndexOf(QLatin1Char(':'), end - 1);
-
914 if (colonIndex < from)
evaluated: colonIndex < from
TRUEFALSE
yes
Evaluation Count:3145
yes
Evaluation Count:735
735-3145
915 colonIndex = -1;
executed: colonIndex = -1;
Execution Count:3142
3142
916 -
917 if (uint(colonIndex) < uint(end)) {
evaluated: uint(colonIndex) < uint(end)
TRUEFALSE
yes
Evaluation Count:735
yes
Evaluation Count:3143
735-3143
918 if (auth.at(from).unicode() == '[') {
evaluated: auth.at(from).unicode() == '['
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:691
44-691
919 // check if colonIndex isn't inside the "[...]" part -
920 int closingBracket = auth.indexOf(QLatin1Char(']'), from);
executed (the execution status of this line is deduced): int closingBracket = auth.indexOf(QLatin1Char(']'), from);
-
921 if (uint(closingBracket) > uint(colonIndex))
evaluated: uint(closingBracket) > uint(colonIndex)
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:6
6-38
922 colonIndex = -1;
executed: colonIndex = -1;
Execution Count:38
38
923 }
executed: }
Execution Count:44
44
924 }
executed: }
Execution Count:735
735
925 -
926 if (colonIndex == end - 1) {
evaluated: colonIndex == end - 1
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3864
9-3864
927 // found a colon but no digits after it -
928 setError(PortEmptyError, auth, colonIndex + 1);
executed (the execution status of this line is deduced): setError(PortEmptyError, auth, colonIndex + 1);
-
929 } else if (uint(colonIndex) < uint(end)) {
executed: }
Execution Count:9
evaluated: uint(colonIndex) < uint(end)
TRUEFALSE
yes
Evaluation Count:688
yes
Evaluation Count:3176
9-3176
930 unsigned long x = 0;
executed (the execution status of this line is deduced): unsigned long x = 0;
-
931 for (int i = colonIndex + 1; i < end; ++i) {
evaluated: i < end
TRUEFALSE
yes
Evaluation Count:2863
yes
Evaluation Count:681
681-2863
932 ushort c = auth.at(i).unicode();
executed (the execution status of this line is deduced): ushort c = auth.at(i).unicode();
-
933 if (c >= '0' && c <= '9') {
evaluated: c >= '0'
TRUEFALSE
yes
Evaluation Count:2862
yes
Evaluation Count:1
evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:2856
yes
Evaluation Count:6
1-2862
934 x *= 10;
executed (the execution status of this line is deduced): x *= 10;
-
935 x += c - '0';
executed (the execution status of this line is deduced): x += c - '0';
-
936 } else {
executed: }
Execution Count:2856
2856
937 x = ulong(-1); // x != ushort(x)
executed (the execution status of this line is deduced): x = ulong(-1);
-
938 break;
executed: break;
Execution Count:7
7
939 } -
940 } -
941 if (x == ushort(x)) {
evaluated: x == ushort(x)
TRUEFALSE
yes
Evaluation Count:678
yes
Evaluation Count:10
10-678
942 port = ushort(x);
executed (the execution status of this line is deduced): port = ushort(x);
-
943 } else {
executed: }
Execution Count:678
678
944 setError(InvalidPortError, auth, colonIndex + 1);
executed (the execution status of this line is deduced): setError(InvalidPortError, auth, colonIndex + 1);
-
945 if (mode == QUrl::StrictMode)
evaluated: mode == QUrl::StrictMode
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6
4-6
946 break;
executed: break;
Execution Count:4
4
947 }
executed: }
Execution Count:6
6
948 } else { -
949 port = -1;
executed (the execution status of this line is deduced): port = -1;
-
950 }
executed: }
Execution Count:3173
3173
951 -
952 setHost(auth, from, qMin<uint>(end, colonIndex), mode);
executed (the execution status of this line is deduced): setHost(auth, from, qMin<uint>(end, colonIndex), mode);
-
953 if (mode == QUrl::StrictMode && !validateComponent(Host, auth, from, qMin<uint>(end, colonIndex))) {
evaluated: mode == QUrl::StrictMode
TRUEFALSE
yes
Evaluation Count:61
yes
Evaluation Count:3806
evaluated: !validateComponent(Host, auth, from, qMin<uint>(end, colonIndex))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:59
2-3806
954 // clear host too -
955 sectionIsPresent &= ~Authority;
executed (the execution status of this line is deduced): sectionIsPresent &= ~Authority;
-
956 break;
executed: break;
Execution Count:2
2
957 } -
958 -
959 // success -
960 return;
executed: return;
Execution Count:3862
3862
961 } -
962 // clear all sections but host -
963 sectionIsPresent &= ~Authority | Host;
executed (the execution status of this line is deduced): sectionIsPresent &= ~Authority | Host;
-
964 userName.clear();
executed (the execution status of this line is deduced): userName.clear();
-
965 password.clear();
executed (the execution status of this line is deduced): password.clear();
-
966 host.clear();
executed (the execution status of this line is deduced): host.clear();
-
967 port = -1;
executed (the execution status of this line is deduced): port = -1;
-
968}
executed: }
Execution Count:161
161
969 -
970inline void QUrlPrivate::setUserInfo(const QString &userInfo, int from, int end) -
971{ -
972 int delimIndex = userInfo.indexOf(QLatin1Char(':'), from);
executed (the execution status of this line is deduced): int delimIndex = userInfo.indexOf(QLatin1Char(':'), from);
-
973 setUserName(userInfo, from, qMin<uint>(delimIndex, end));
executed (the execution status of this line is deduced): setUserName(userInfo, from, qMin<uint>(delimIndex, end));
-
974 -
975 if (uint(delimIndex) >= uint(end)) {
evaluated: uint(delimIndex) >= uint(end)
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:110
72-110
976 password.clear();
executed (the execution status of this line is deduced): password.clear();
-
977 sectionIsPresent &= ~Password;
executed (the execution status of this line is deduced): sectionIsPresent &= ~Password;
-
978 } else {
executed: }
Execution Count:72
72
979 setPassword(userInfo, delimIndex + 1, end);
executed (the execution status of this line is deduced): setPassword(userInfo, delimIndex + 1, end);
-
980 }
executed: }
Execution Count:110
110
981} -
982 -
983inline void QUrlPrivate::setUserName(const QString &value, int from, int end) -
984{ -
985 sectionIsPresent |= UserName;
executed (the execution status of this line is deduced): sectionIsPresent |= UserName;
-
986 userName = recodeFromUser(value, decodedUserNameInIsolationActions, from, end);
executed (the execution status of this line is deduced): userName = recodeFromUser(value, decodedUserNameInIsolationActions, from, end);
-
987}
executed: }
Execution Count:2021
2021
988 -
989inline void QUrlPrivate::setPassword(const QString &value, int from, int end) -
990{ -
991 sectionIsPresent |= Password;
executed (the execution status of this line is deduced): sectionIsPresent |= Password;
-
992 password = recodeFromUser(value, decodedPasswordInIsolationActions, from, end);
executed (the execution status of this line is deduced): password = recodeFromUser(value, decodedPasswordInIsolationActions, from, end);
-
993}
executed: }
Execution Count:543
543
994 -
995inline void QUrlPrivate::setPath(const QString &value, int from, int end) -
996{ -
997 // sectionIsPresent |= Path; // not used, save some cycles -
998 path = recodeFromUser(value, decodedPathInIsolationActions, from, end);
executed (the execution status of this line is deduced): path = recodeFromUser(value, decodedPathInIsolationActions, from, end);
-
999}
executed: }
Execution Count:9939
9939
1000 -
1001inline void QUrlPrivate::setFragment(const QString &value, int from, int end) -
1002{ -
1003 sectionIsPresent |= Fragment;
executed (the execution status of this line is deduced): sectionIsPresent |= Fragment;
-
1004 fragment = recodeFromUser(value, decodedFragmentInIsolationActions, from, end);
executed (the execution status of this line is deduced): fragment = recodeFromUser(value, decodedFragmentInIsolationActions, from, end);
-
1005}
executed: }
Execution Count:1466
1466
1006 -
1007inline void QUrlPrivate::setQuery(const QString &value, int from, int iend) -
1008{ -
1009 sectionIsPresent |= Query;
executed (the execution status of this line is deduced): sectionIsPresent |= Query;
-
1010 -
1011 // use the default actions for the query (don't set QUrl::DecodeAllDelimiters) -
1012 QString output;
executed (the execution status of this line is deduced): QString output;
-
1013 const QChar *begin = value.constData() + from;
executed (the execution status of this line is deduced): const QChar *begin = value.constData() + from;
-
1014 const QChar *end = value.constData() + iend;
executed (the execution status of this line is deduced): const QChar *end = value.constData() + iend;
-
1015 -
1016 // leave delimiters alone but decode the rest -
1017 if (qt_urlRecode(output, begin, end, QUrl::EncodeDelimiters,
evaluated: qt_urlRecode(output, begin, end, QUrl::EncodeDelimiters, decodedQueryInIsolationActions)
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:360
39-360
1018 decodedQueryInIsolationActions))
evaluated: qt_urlRecode(output, begin, end, QUrl::EncodeDelimiters, decodedQueryInIsolationActions)
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:360
39-360
1019 query = output;
executed: query = output;
Execution Count:39
39
1020 else -
1021 query = value.mid(from, iend - from);
executed: query = value.mid(from, iend - from);
Execution Count:360
360
1022} -
1023 -
1024// Host handling -
1025// The RFC says the host is: -
1026// host = IP-literal / IPv4address / reg-name -
1027// IP-literal = "[" ( IPv6address / IPvFuture ) "]" -
1028// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) -
1029// [a strict definition of IPv6Address and IPv4Address] -
1030// reg-name = *( unreserved / pct-encoded / sub-delims ) -
1031// -
1032// We deviate from the standard in all but IPvFuture. For IPvFuture we accept -
1033// and store only exactly what the RFC says we should. No percent-encoding is -
1034// permitted in this field, so Unicode characters and space aren't either. -
1035// -
1036// For IPv4 addresses, we accept broken addresses like inet_aton does (that is, -
1037// less than three dots). However, we correct the address to the proper form -
1038// and store the corrected address. After correction, we comply to the RFC and -
1039// it's exclusively composed of unreserved characters. -
1040// -
1041// For IPv6 addresses, we accept addresses including trailing (embedded) IPv4 -
1042// addresses, the so-called v4-compat and v4-mapped addresses. We also store -
1043// those addresses like that in the hostname field, which violates the spec. -
1044// IPv6 hosts are stored with the square brackets in the QString. It also -
1045// requires no transformation in any way. -
1046// -
1047// As for registered names, it's the other way around: we accept only valid -
1048// hostnames as specified by STD 3 and IDNA. That means everything we accept is -
1049// valid in the RFC definition above, but there are many valid reg-names -
1050// according to the RFC that we do not accept in the name of security. Since we -
1051// do accept IDNA, reg-names are subject to ACE encoding and decoding, which is -
1052// specified by the DecodeUnicode flag. The hostname is stored in its Unicode form. -
1053 -
1054inline void QUrlPrivate::appendHost(QString &appendTo, QUrl::FormattingOptions options) const -
1055{ -
1056 // this is the only flag that matters -
1057 options &= QUrl::EncodeUnicode;
executed (the execution status of this line is deduced): options &= QUrl::EncodeUnicode;
-
1058 if (host.isEmpty())
evaluated: host.isEmpty()
TRUEFALSE
yes
Evaluation Count:896
yes
Evaluation Count:8126
896-8126
1059 return;
executed: return;
Execution Count:896
896
1060 if (host.at(0).unicode() == '[') {
evaluated: host.at(0).unicode() == '['
TRUEFALSE
yes
Evaluation Count:120
yes
Evaluation Count:8007
120-8007
1061 // IPv6Address and IPvFuture address never require any transformation -
1062 appendTo += host;
executed (the execution status of this line is deduced): appendTo += host;
-
1063 } else {
executed: }
Execution Count:120
120
1064 // this is either an IPv4Address or a reg-name -
1065 // if it is a reg-name, it is already stored in Unicode form -
1066 if (options == QUrl::EncodeUnicode)
evaluated: options == QUrl::EncodeUnicode
TRUEFALSE
yes
Evaluation Count:3014
yes
Evaluation Count:4993
3014-4993
1067 appendTo += qt_ACE_do(host, ToAceOnly);
executed: appendTo += qt_ACE_do(host, ToAceOnly);
Execution Count:3014
3014
1068 else -
1069 appendTo += host;
executed: appendTo += host;
Execution Count:4993
4993
1070 } -
1071} -
1072 -
1073// the whole IPvFuture is passed and parsed here, including brackets; -
1074// returns null if the parsing was successful, or the QChar of the first failure -
1075static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar *end) -
1076{ -
1077 // IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) -
1078 static const char acceptable[] = -
1079 "!$&'()*+,;=" // sub-delims -
1080 ":" // ":" -
1081 "-._~"; // unreserved -
1082 -
1083 // the brackets and the "v" have been checked -
1084 if (begin[3].unicode() != '.')
partially evaluated: begin[3].unicode() != '.'
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1085 return &begin[3];
executed: return &begin[3];
Execution Count:1
1
1086 if ((begin[2].unicode() >= 'A' && begin[2].unicode() >= 'F') ||
never evaluated: begin[2].unicode() >= 'A'
never evaluated: begin[2].unicode() >= 'F'
0
1087 (begin[2].unicode() >= 'a' && begin[2].unicode() <= 'f') ||
never evaluated: begin[2].unicode() >= 'a'
never evaluated: begin[2].unicode() <= 'f'
0
1088 (begin[2].unicode() >= '0' && begin[2].unicode() <= '9')) {
never evaluated: begin[2].unicode() >= '0'
never evaluated: begin[2].unicode() <= '9'
0
1089 // this is so unlikely that we'll just go down the slow path -
1090 // decode the whole string, skipping the "[vH." and "]" which we already know to be there -
1091 host += QString::fromRawData(begin, 4);
never executed (the execution status of this line is deduced): host += QString::fromRawData(begin, 4);
-
1092 begin += 4;
never executed (the execution status of this line is deduced): begin += 4;
-
1093 --end;
never executed (the execution status of this line is deduced): --end;
-
1094 -
1095 QString decoded;
never executed (the execution status of this line is deduced): QString decoded;
-
1096 if (qt_urlRecode(decoded, begin, end, QUrl::FullyEncoded, 0)) {
never evaluated: qt_urlRecode(decoded, begin, end, QUrl::FullyEncoded, 0)
0
1097 begin = decoded.constBegin();
never executed (the execution status of this line is deduced): begin = decoded.constBegin();
-
1098 end = decoded.constEnd();
never executed (the execution status of this line is deduced): end = decoded.constEnd();
-
1099 }
never executed: }
0
1100 -
1101 for ( ; begin != end; ++begin) {
never evaluated: begin != end
0
1102 if (begin->unicode() >= 'A' && begin->unicode() <= 'Z')
never evaluated: begin->unicode() >= 'A'
never evaluated: begin->unicode() <= 'Z'
0
1103 host += *begin;
never executed: host += *begin;
0
1104 else if (begin->unicode() >= 'a' && begin->unicode() <= 'z')
never evaluated: begin->unicode() >= 'a'
never evaluated: begin->unicode() <= 'z'
0
1105 host += *begin;
never executed: host += *begin;
0
1106 else if (begin->unicode() >= '0' && begin->unicode() <= '9')
never evaluated: begin->unicode() >= '0'
never evaluated: begin->unicode() <= '9'
0
1107 host += *begin;
never executed: host += *begin;
0
1108 else if (begin->unicode() < 0x80 && strchr(acceptable, begin->unicode()) != 0)
never evaluated: begin->unicode() < 0x80
never evaluated: strchr(acceptable, begin->unicode()) != 0
0
1109 host += *begin;
never executed: host += *begin;
0
1110 else -
1111 return begin;
never executed: return begin;
0
1112 } -
1113 host += QLatin1Char(']');
never executed (the execution status of this line is deduced): host += QLatin1Char(']');
-
1114 return 0;
never executed: return 0;
0
1115 } -
1116 return &begin[2];
never executed: return &begin[2];
0
1117} -
1118 -
1119// ONLY the IPv6 address is parsed here, WITHOUT the brackets -
1120static bool parseIp6(QString &host, const QChar *begin, const QChar *end) -
1121{ -
1122 QIPAddressUtils::IPv6Address address;
executed (the execution status of this line is deduced): QIPAddressUtils::IPv6Address address;
-
1123 if (!QIPAddressUtils::parseIp6(address, begin, end)) {
evaluated: !QIPAddressUtils::parseIp6(address, begin, end)
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:69
32-69
1124 // IPv6 failed parsing, check if it was a percent-encoded character in -
1125 // the middle and try again -
1126 QString decoded;
executed (the execution status of this line is deduced): QString decoded;
-
1127 if (!qt_urlRecode(decoded, begin, end, QUrl::FullyEncoded, 0)) {
evaluated: !qt_urlRecode(decoded, begin, end, QUrl::FullyEncoded, 0)
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:11
11-21
1128 // no transformation, nothing to re-parse -
1129 return false;
executed: return false;
Execution Count:21
21
1130 } -
1131 -
1132 // recurse -
1133 // if the parsing fails again, the qt_urlRecode above will return 0 -
1134 return parseIp6(host, decoded.constBegin(), decoded.constEnd());
executed: return parseIp6(host, decoded.constBegin(), decoded.constEnd());
Execution Count:11
11
1135 } -
1136 -
1137 host.reserve(host.size() + (end - begin));
executed (the execution status of this line is deduced): host.reserve(host.size() + (end - begin));
-
1138 host += QLatin1Char('[');
executed (the execution status of this line is deduced): host += QLatin1Char('[');
-
1139 QIPAddressUtils::toString(host, address);
executed (the execution status of this line is deduced): QIPAddressUtils::toString(host, address);
-
1140 host += QLatin1Char(']');
executed (the execution status of this line is deduced): host += QLatin1Char(']');
-
1141 return true;
executed: return true;
Execution Count:69
69
1142} -
1143 -
1144inline bool QUrlPrivate::setHost(const QString &value, int from, int iend, QUrl::ParsingMode mode) -
1145{ -
1146 const QChar *begin = value.constData() + from;
executed (the execution status of this line is deduced): const QChar *begin = value.constData() + from;
-
1147 const QChar *end = value.constData() + iend;
executed (the execution status of this line is deduced): const QChar *end = value.constData() + iend;
-
1148 -
1149 const int len = end - begin;
executed (the execution status of this line is deduced): const int len = end - begin;
-
1150 host.clear();
executed (the execution status of this line is deduced): host.clear();
-
1151 sectionIsPresent |= Host;
executed (the execution status of this line is deduced): sectionIsPresent |= Host;
-
1152 if (len == 0)
evaluated: len == 0
TRUEFALSE
yes
Evaluation Count:176
yes
Evaluation Count:6789
176-6789
1153 return true;
executed: return true;
Execution Count:176
176
1154 -
1155 if (begin[0].unicode() == '[') {
evaluated: begin[0].unicode() == '['
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:6702
92-6702
1156 // IPv6Address or IPvFuture -
1157 // smallest IPv6 address is "[::]" (len = 4) -
1158 // smallest IPvFuture address is "[v7.X]" (len = 6) -
1159 if (end[-1].unicode() != ']') {
evaluated: end[-1].unicode() != ']'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:91
1-91
1160 setError(HostMissingEndBracket, value);
executed (the execution status of this line is deduced): setError(HostMissingEndBracket, value);
-
1161 return false;
executed: return false;
Execution Count:1
1
1162 } -
1163 -
1164 if (len > 5 && begin[1].unicode() == 'v') {
evaluated: len > 5
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:19
evaluated: begin[1].unicode() == 'v'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:71
1-72
1165 const QChar *c = parseIpFuture(host, begin, end);
executed (the execution status of this line is deduced): const QChar *c = parseIpFuture(host, begin, end);
-
1166 if (c)
partially evaluated: c
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1167 setError(InvalidIPvFutureError, value, c - value.constData());
executed: setError(InvalidIPvFutureError, value, c - value.constData());
Execution Count:1
1
1168 return !c;
executed: return !c;
Execution Count:1
1
1169 } -
1170 -
1171 if (parseIp6(host, begin + 1, end - 1))
evaluated: parseIp6(host, begin + 1, end - 1)
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:21
21-69
1172 return true;
executed: return true;
Execution Count:69
69
1173 -
1174 setError(begin[1].unicode() == 'v' ? InvalidIPvFutureError : InvalidIPv6AddressError,
executed (the execution status of this line is deduced): setError(begin[1].unicode() == 'v' ? InvalidIPvFutureError : InvalidIPv6AddressError,
-
1175 value, from);
executed (the execution status of this line is deduced): value, from);
-
1176 return false;
executed: return false;
Execution Count:21
21
1177 } -
1178 -
1179 // check if it's an IPv4 address -
1180 QIPAddressUtils::IPv4Address ip4;
executed (the execution status of this line is deduced): QIPAddressUtils::IPv4Address ip4;
-
1181 if (QIPAddressUtils::parseIp4(ip4, begin, end)) {
evaluated: QIPAddressUtils::parseIp4(ip4, begin, end)
TRUEFALSE
yes
Evaluation Count:629
yes
Evaluation Count:6016
629-6016
1182 // yes, it was -
1183 QIPAddressUtils::toString(host, ip4);
executed (the execution status of this line is deduced): QIPAddressUtils::toString(host, ip4);
-
1184 return true;
executed: return true;
Execution Count:629
629
1185 } -
1186 -
1187 // This is probably a reg-name. -
1188 // But it can also be an encoded string that, when decoded becomes one -
1189 // of the types above. -
1190 // -
1191 // Two types of encoding are possible: -
1192 // percent encoding (e.g., "%31%30%2E%30%2E%30%2E%31" -> "10.0.0.1") -
1193 // Unicode encoding (some non-ASCII characters case-fold to digits -
1194 // when nameprepping is done) -
1195 // -
1196 // The qt_ACE_do function below applies nameprepping and the STD3 check. -
1197 // That means a Unicode string may become an IPv4 address, but it cannot -
1198 // produce a '[' or a '%'. -
1199 -
1200 // check for percent-encoding first -
1201 QString s;
executed (the execution status of this line is deduced): QString s;
-
1202 if (mode == QUrl::TolerantMode && qt_urlRecode(s, begin, end, QUrl::DecodeReserved, 0)) {
evaluated: mode == QUrl::TolerantMode
TRUEFALSE
yes
Evaluation Count:5925
yes
Evaluation Count:89
evaluated: qt_urlRecode(s, begin, end, QUrl::DecodeReserved, 0)
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:5927
40-5927
1203 // something was decoded -
1204 // anything encoded left? -
1205 int pos = s.indexOf(QChar(0x25)); // '%'
executed (the execution status of this line is deduced): int pos = s.indexOf(QChar(0x25));
-
1206 if (pos != -1) {
evaluated: pos != -1
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:31
9-31
1207 setError(InvalidRegNameError, s, pos);
executed (the execution status of this line is deduced): setError(InvalidRegNameError, s, pos);
-
1208 return false;
executed: return false;
Execution Count:9
9
1209 } -
1210 -
1211 // recurse -
1212 return setHost(s, 0, s.length(), QUrl::StrictMode);
executed: return setHost(s, 0, s.length(), QUrl::StrictMode);
Execution Count:31
31
1213 } -
1214 -
1215 s = qt_ACE_do(QString::fromRawData(begin, len), NormalizeAce);
executed (the execution status of this line is deduced): s = qt_ACE_do(QString::fromRawData(begin, len), NormalizeAce);
-
1216 if (s.isEmpty()) {
evaluated: s.isEmpty()
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:5980
46-5980
1217 setError(InvalidRegNameError, value);
executed (the execution status of this line is deduced): setError(InvalidRegNameError, value);
-
1218 return false;
executed: return false;
Execution Count:46
46
1219 } -
1220 -
1221 // check IPv4 again -
1222 if (QIPAddressUtils::parseIp4(ip4, s.constBegin(), s.constEnd())) {
partially evaluated: QIPAddressUtils::parseIp4(ip4, s.constBegin(), s.constEnd())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5929
0-5929
1223 QIPAddressUtils::toString(host, ip4);
never executed (the execution status of this line is deduced): QIPAddressUtils::toString(host, ip4);
-
1224 } else {
never executed: }
0
1225 host = s;
executed (the execution status of this line is deduced): host = s;
-
1226 }
executed: }
Execution Count:5950
5950
1227 return true;
executed: return true;
Execution Count:5968
5968
1228} -
1229 -
1230inline void QUrlPrivate::parse(const QString &url, QUrl::ParsingMode parsingMode) -
1231{ -
1232 // URI-reference = URI / relative-ref -
1233 // URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] -
1234 // relative-ref = relative-part [ "?" query ] [ "#" fragment ] -
1235 // hier-part = "//" authority path-abempty -
1236 // / other path types -
1237 // relative-part = "//" authority path-abempty -
1238 // / other path types here -
1239 -
1240 sectionIsPresent = 0;
executed (the execution status of this line is deduced): sectionIsPresent = 0;
-
1241 clearError();
executed (the execution status of this line is deduced): clearError();
-
1242 -
1243 // find the important delimiters -
1244 int colon = -1;
executed (the execution status of this line is deduced): int colon = -1;
-
1245 int question = -1;
executed (the execution status of this line is deduced): int question = -1;
-
1246 int hash = -1;
executed (the execution status of this line is deduced): int hash = -1;
-
1247 const int len = url.length();
executed (the execution status of this line is deduced): const int len = url.length();
-
1248 const QChar *const begin = url.constData();
executed (the execution status of this line is deduced): const QChar *const begin = url.constData();
-
1249 const ushort *const data = reinterpret_cast<const ushort *>(begin);
executed (the execution status of this line is deduced): const ushort *const data = reinterpret_cast<const ushort *>(begin);
-
1250 -
1251 for (int i = 0; i < len; ++i) {
evaluated: i < len
TRUEFALSE
yes
Evaluation Count:180729
yes
Evaluation Count:7689
7689-180729
1252 register uint uc = data[i];
executed (the execution status of this line is deduced): register uint uc = data[i];
-
1253 if (uc == '#' && hash == -1) {
evaluated: uc == '#'
TRUEFALSE
yes
Evaluation Count:126
yes
Evaluation Count:180619
partially evaluated: hash == -1
TRUEFALSE
yes
Evaluation Count:126
no
Evaluation Count:0
0-180619
1254 hash = i;
executed (the execution status of this line is deduced): hash = i;
-
1255 -
1256 // nothing more to be found -
1257 break;
executed: break;
Execution Count:126
126
1258 } -
1259 -
1260 if (question == -1) {
evaluated: question == -1
TRUEFALSE
yes
Evaluation Count:177615
yes
Evaluation Count:2995
2995-177615
1261 if (uc == ':' && colon == -1)
evaluated: uc == ':'
TRUEFALSE
yes
Evaluation Count:5261
yes
Evaluation Count:172468
evaluated: colon == -1
TRUEFALSE
yes
Evaluation Count:4241
yes
Evaluation Count:1015
1015-172468
1262 colon = i;
executed: colon = i;
Execution Count:4238
4238
1263 else if (uc == '?')
evaluated: uc == '?'
TRUEFALSE
yes
Evaluation Count:261
yes
Evaluation Count:173250
261-173250
1264 question = i;
executed: question = i;
Execution Count:261
261
1265 } -
1266 }
executed: }
Execution Count:180678
180678
1267 -
1268 // check if we have a scheme -
1269 int hierStart;
executed (the execution status of this line is deduced): int hierStart;
-
1270 if (colon != -1 && setScheme(url, colon, /* don't set error */ false)) {
evaluated: colon != -1
TRUEFALSE
yes
Evaluation Count:4243
yes
Evaluation Count:3581
evaluated: setScheme(url, colon, false)
TRUEFALSE
yes
Evaluation Count:4206
yes
Evaluation Count:32
32-4243
1271 hierStart = colon + 1;
executed (the execution status of this line is deduced): hierStart = colon + 1;
-
1272 } else {
executed: }
Execution Count:4206
4206
1273 // recover from a failed scheme: it might not have been a scheme at all -
1274 scheme.clear();
executed (the execution status of this line is deduced): scheme.clear();
-
1275 sectionIsPresent = 0;
executed (the execution status of this line is deduced): sectionIsPresent = 0;
-
1276 hierStart = 0;
executed (the execution status of this line is deduced): hierStart = 0;
-
1277 }
executed: }
Execution Count:3613
3613
1278 -
1279 int pathStart;
executed (the execution status of this line is deduced): int pathStart;
-
1280 int hierEnd = qMin<uint>(qMin<uint>(question, hash), len);
executed (the execution status of this line is deduced): int hierEnd = qMin<uint>(qMin<uint>(question, hash), len);
-
1281 if (hierEnd - hierStart >= 2 && data[hierStart] == '/' && data[hierStart + 1] == '/') {
evaluated: hierEnd - hierStart >= 2
TRUEFALSE
yes
Evaluation Count:7635
yes
Evaluation Count:186
evaluated: data[hierStart] == '/'
TRUEFALSE
yes
Evaluation Count:4113
yes
Evaluation Count:3530
evaluated: data[hierStart + 1] == '/'
TRUEFALSE
yes
Evaluation Count:4005
yes
Evaluation Count:102
102-7635
1282 // we have an authority, it ends at the first slash after these -
1283 int authorityEnd = hierEnd;
executed (the execution status of this line is deduced): int authorityEnd = hierEnd;
-
1284 for (int i = hierStart + 2; i < authorityEnd ; ++i) {
evaluated: i < authorityEnd
TRUEFALSE
yes
Evaluation Count:64155
yes
Evaluation Count:2543
2543-64155
1285 if (data[i] == '/') {
evaluated: data[i] == '/'
TRUEFALSE
yes
Evaluation Count:1474
yes
Evaluation Count:62670
1474-62670
1286 authorityEnd = i;
executed (the execution status of this line is deduced): authorityEnd = i;
-
1287 break;
executed: break;
Execution Count:1474
1474
1288 } -
1289 }
executed: }
Execution Count:62689
62689
1290 -
1291 setAuthority(url, hierStart + 2, authorityEnd, parsingMode);
executed (the execution status of this line is deduced): setAuthority(url, hierStart + 2, authorityEnd, parsingMode);
-
1292 -
1293 // even if we failed to set the authority properly, let's try to recover -
1294 pathStart = authorityEnd;
executed (the execution status of this line is deduced): pathStart = authorityEnd;
-
1295 setPath(url, pathStart, hierEnd);
executed (the execution status of this line is deduced): setPath(url, pathStart, hierEnd);
-
1296 } else {
executed: }
Execution Count:3991
3991
1297 userName.clear();
executed (the execution status of this line is deduced): userName.clear();
-
1298 password.clear();
executed (the execution status of this line is deduced): password.clear();
-
1299 host.clear();
executed (the execution status of this line is deduced): host.clear();
-
1300 port = -1;
executed (the execution status of this line is deduced): port = -1;
-
1301 pathStart = hierStart;
executed (the execution status of this line is deduced): pathStart = hierStart;
-
1302 -
1303 if (hierStart < hierEnd)
evaluated: hierStart < hierEnd
TRUEFALSE
yes
Evaluation Count:3654
yes
Evaluation Count:164
164-3654
1304 setPath(url, hierStart, hierEnd);
executed: setPath(url, hierStart, hierEnd);
Execution Count:3653
3653
1305 else -
1306 path.clear();
executed: path.clear();
Execution Count:164
164
1307 } -
1308 -
1309 if (uint(question) < uint(hash))
evaluated: uint(question) < uint(hash)
TRUEFALSE
yes
Evaluation Count:261
yes
Evaluation Count:7532
261-7532
1310 setQuery(url, question + 1, qMin<uint>(hash, len));
executed: setQuery(url, question + 1, qMin<uint>(hash, len));
Execution Count:261
261
1311 -
1312 if (hash != -1)
evaluated: hash != -1
TRUEFALSE
yes
Evaluation Count:126
yes
Evaluation Count:7671
126-7671
1313 setFragment(url, hash + 1, len);
executed: setFragment(url, hash + 1, len);
Execution Count:126
126
1314 -
1315 if (error || parsingMode == QUrl::TolerantMode)
evaluated: error
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:7760
evaluated: parsingMode == QUrl::TolerantMode
TRUEFALSE
yes
Evaluation Count:7707
yes
Evaluation Count:61
35-7760
1316 return;
executed: return;
Execution Count:7748
7748
1317 -
1318 // The parsing so far was partially tolerant of errors, except for the -
1319 // scheme parser (which is always strict) and the authority (which was -
1320 // executed in strict mode). -
1321 // If we haven't found any errors so far, continue the strict-mode parsing -
1322 // from the path component onwards. -
1323 -
1324 if (!validateComponent(Path, url, pathStart, hierEnd))
evaluated: !validateComponent(Path, url, pathStart, hierEnd)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:56
5-56
1325 return;
executed: return;
Execution Count:5
5
1326 if (uint(question) < uint(hash) && !validateComponent(Query, url, question + 1, qMin<uint>(hash, len)))
evaluated: uint(question) < uint(hash)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:55
partially evaluated: !validateComponent(Query, url, question + 1, qMin<uint>(hash, len))
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-55
1327 return;
executed: return;
Execution Count:1
1
1328 if (hash != -1)
evaluated: hash != -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:54
1-54
1329 validateComponent(Fragment, url, hash + 1, len);
executed: validateComponent(Fragment, url, hash + 1, len);
Execution Count:1
1
1330}
executed: }
Execution Count:55
55
1331 -
1332/* -
1333 From http://www.ietf.org/rfc/rfc3986.txt, 5.2.3: Merge paths -
1334 -
1335 Returns a merge of the current path with the relative path passed -
1336 as argument. -
1337 -
1338 Note: \a relativePath is relative (does not start with '/'). -
1339*/ -
1340inline QString QUrlPrivate::mergePaths(const QString &relativePath) const -
1341{ -
1342 // If the base URI has a defined authority component and an empty -
1343 // path, then return a string consisting of "/" concatenated with -
1344 // the reference's path; otherwise, -
1345 if (!host.isEmpty() && path.isEmpty())
evaluated: !host.isEmpty()
TRUEFALSE
yes
Evaluation Count:1028
yes
Evaluation Count:2338
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:987
yes
Evaluation Count:44
44-2338
1346 return QLatin1Char('/') + relativePath;
executed: return QLatin1Char('/') + relativePath;
Execution Count:987
987
1347 -
1348 // Return a string consisting of the reference's path component -
1349 // appended to all but the last segment of the base URI's path -
1350 // (i.e., excluding any characters after the right-most "/" in the -
1351 // base URI path, or excluding the entire base URI path if it does -
1352 // not contain any "/" characters). -
1353 QString newPath;
executed (the execution status of this line is deduced): QString newPath;
-
1354 if (!path.contains(QLatin1Char('/')))
evaluated: !path.contains(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:2363
19-2363
1355 newPath = relativePath;
executed: newPath = relativePath;
Execution Count:19
19
1356 else -
1357 newPath = path.leftRef(path.lastIndexOf(QLatin1Char('/')) + 1) + relativePath;
executed: newPath = path.leftRef(path.lastIndexOf(QLatin1Char('/')) + 1) + relativePath;
Execution Count:2363
2363
1358 -
1359 return newPath;
executed: return newPath;
Execution Count:2382
2382
1360} -
1361 -
1362/* -
1363 From http://www.ietf.org/rfc/rfc3986.txt, 5.2.4: Remove dot segments -
1364 -
1365 Removes unnecessary ../ and ./ from the path. Used for normalizing -
1366 the URL. -
1367*/ -
1368static void removeDotsFromPath(QString *path) -
1369{ -
1370 // The input buffer is initialized with the now-appended path -
1371 // components and the output buffer is initialized to the empty -
1372 // string. -
1373 QChar *out = path->data();
executed (the execution status of this line is deduced): QChar *out = path->data();
-
1374 const QChar *in = out;
executed (the execution status of this line is deduced): const QChar *in = out;
-
1375 const QChar *end = out + path->size();
executed (the execution status of this line is deduced): const QChar *end = out + path->size();
-
1376 -
1377 // If the input buffer consists only of -
1378 // "." or "..", then remove that from the input -
1379 // buffer; -
1380 if (path->size() == 1 && in[0].unicode() == '.')
evaluated: path->size() == 1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4461
partially evaluated: in[0].unicode() == '.'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-4461
1381 ++in;
never executed: ++in;
0
1382 else if (path->size() == 2 && in[0].unicode() == '.' && in[1].unicode() == '.')
evaluated: path->size() == 2
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4462
partially evaluated: in[0].unicode() == '.'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: in[1].unicode() == '.'
0-4462
1383 in += 2;
never executed: in += 2;
0
1384 // While the input buffer is not empty, loop: -
1385 while (in < end) {
evaluated: in < end
TRUEFALSE
yes
Evaluation Count:37749
yes
Evaluation Count:4462
4462-37749
1386 -
1387 // otherwise, if the input buffer begins with a prefix of "../" or "./", -
1388 // then remove that prefix from the input buffer; -
1389 if (path->size() >= 2 && in[0].unicode() == '.' && in[1].unicode() == '/')
evaluated: path->size() >= 2
TRUEFALSE
yes
Evaluation Count:37745
yes
Evaluation Count:3
evaluated: in[0].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:37745
partially evaluated: in[1].unicode() == '/'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-37745
1390 in += 2;
never executed: in += 2;
0
1391 else if (path->size() >= 3 && in[0].unicode() == '.'
evaluated: path->size() >= 3
TRUEFALSE
yes
Evaluation Count:37745
yes
Evaluation Count:6
evaluated: in[0].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:37745
1-37745
1392 && in[1].unicode() == '.' && in[2].unicode() == '/')
partially evaluated: in[1].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: in[2].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1393 in += 3;
executed: in += 3;
Execution Count:1
1
1394 -
1395 // otherwise, if the input buffer begins with a prefix of -
1396 // "/./" or "/.", where "." is a complete path segment, -
1397 // then replace that prefix with "/" in the input buffer; -
1398 if (in <= end - 3 && in[0].unicode() == '/' && in[1].unicode() == '.'
evaluated: in <= end - 3
TRUEFALSE
yes
Evaluation Count:37700
yes
Evaluation Count:53
evaluated: in[0].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:37669
yes
Evaluation Count:29
evaluated: in[1].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:37625
29-37700
1399 && in[2].unicode() == '/') {
evaluated: in[2].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:37
7-37
1400 in += 2;
executed (the execution status of this line is deduced): in += 2;
-
1401 continue;
executed: continue;
Execution Count:7
7
1402 } else if (in == end - 2 && in[0].unicode() == '/' && in[1].unicode() == '.') {
evaluated: in == end - 2
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:37715
partially evaluated: in[0].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
evaluated: in[1].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:28
0-37715
1403 *out++ = QLatin1Char('/');
executed (the execution status of this line is deduced): *out++ = QLatin1Char('/');
-
1404 in += 2;
executed (the execution status of this line is deduced): in += 2;
-
1405 break;
executed: break;
Execution Count:2
2
1406 } -
1407 -
1408 // otherwise, if the input buffer begins with a prefix -
1409 // of "/../" or "/..", where ".." is a complete path -
1410 // segment, then replace that prefix with "/" in the -
1411 // input buffer and remove the last //segment and its -
1412 // preceding "/" (if any) from the output buffer; -
1413 if (in <= end - 4 && in[0].unicode() == '/' && in[1].unicode() == '.'
evaluated: in <= end - 4
TRUEFALSE
yes
Evaluation Count:37687
yes
Evaluation Count:57
evaluated: in[0].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:37658
yes
Evaluation Count:29
evaluated: in[1].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:37623
29-37687
1414 && in[2].unicode() == '.' && in[3].unicode() == '/') {
partially evaluated: in[2].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
evaluated: in[3].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:1
0-34
1415 while (out > path->constData() && (--out)->unicode() != '/')
evaluated: out > path->constData()
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:8
evaluated: (--out)->unicode() != '/'
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:25
8-96
1416 ;
executed: ;
Execution Count:71
71
1417 if (out == path->constData() && out->unicode() != '/')
evaluated: out == path->constData()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:19
evaluated: out->unicode() != '/'
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:11
3-19
1418 ++in;
executed: ++in;
Execution Count:3
3
1419 in += 3;
executed (the execution status of this line is deduced): in += 3;
-
1420 continue;
executed: continue;
Execution Count:33
33
1421 } else if (in == end - 3 && in[0].unicode() == '/' && in[1].unicode() == '.'
evaluated: in == end - 3
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:37705
partially evaluated: in[0].unicode() == '/'
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
evaluated: in[1].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
0-37705
1422 && in[2].unicode() == '.') {
evaluated: in[2].unicode() == '.'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
1423 while (out > path->constData() && (--out)->unicode() != '/')
partially evaluated: out > path->constData()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
evaluated: (--out)->unicode() != '/'
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
0-4
1424 ;
executed: ;
Execution Count:2
2
1425 if (out->unicode() == '/')
partially evaluated: out->unicode() == '/'
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1426 ++out;
executed: ++out;
Execution Count:2
2
1427 in += 3;
executed (the execution status of this line is deduced): in += 3;
-
1428 break;
executed: break;
Execution Count:2
2
1429 } -
1430 -
1431 // otherwise move the first path segment in -
1432 // the input buffer to the end of the output -
1433 // buffer, including the initial "/" character -
1434 // (if any) and any subsequent characters up -
1435 // to, but not including, the next "/" -
1436 // character or the end of the input buffer. -
1437 *out++ = *in++;
executed (the execution status of this line is deduced): *out++ = *in++;
-
1438 while (in < end && in->unicode() != '/')
evaluated: in < end
TRUEFALSE
yes
Evaluation Count:283716
yes
Evaluation Count:3467
evaluated: in->unicode() != '/'
TRUEFALSE
yes
Evaluation Count:249490
yes
Evaluation Count:34242
3467-283716
1439 *out++ = *in++;
executed: *out++ = *in++;
Execution Count:249493
249493
1440 }
executed: }
Execution Count:37710
37710
1441 path->truncate(out - path->constData());
executed (the execution status of this line is deduced): path->truncate(out - path->constData());
-
1442}
executed: }
Execution Count:4456
4456
1443 -
1444inline QUrlPrivate::ErrorCode QUrlPrivate::validityError(QString *source, int *position) const -
1445{ -
1446 Q_ASSERT(!source == !position);
executed (the execution status of this line is deduced): qt_noop();
-
1447 if (error) {
evaluated: error
TRUEFALSE
yes
Evaluation Count:249
yes
Evaluation Count:10701
249-10701
1448 if (source) {
evaluated: source
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:144
105-144
1449 *source = error->source;
executed (the execution status of this line is deduced): *source = error->source;
-
1450 *position = error->position;
executed (the execution status of this line is deduced): *position = error->position;
-
1451 }
executed: }
Execution Count:105
105
1452 return error->code;
executed: return error->code;
Execution Count:249
249
1453 } -
1454 -
1455 // There are two more cases of invalid URLs that QUrl recognizes and they -
1456 // are only possible with constructed URLs (setXXX methods), not with -
1457 // parsing. Therefore, they are tested here. -
1458 // -
1459 // The two cases are a non-empty path that doesn't start with a slash and: -
1460 // - with an authority -
1461 // - without an authority, without scheme but the path with a colon before -
1462 // the first slash -
1463 // Those cases are considered invalid because toString() would produce a URL -
1464 // that wouldn't be parsed back to the same QUrl. -
1465 -
1466 if (path.isEmpty() || path.at(0) == QLatin1Char('/'))
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:3737
yes
Evaluation Count:6964
evaluated: path.at(0) == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:6448
yes
Evaluation Count:516
516-6964
1467 return NoError;
executed: return NoError;
Execution Count:10185
10185
1468 if (sectionIsPresent & QUrlPrivate::Host) {
evaluated: sectionIsPresent & QUrlPrivate::Host
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:510
6-510
1469 if (source) {
evaluated: source
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
1470 *source = path;
executed (the execution status of this line is deduced): *source = path;
-
1471 *position = 0;
executed (the execution status of this line is deduced): *position = 0;
-
1472 }
executed: }
Execution Count:1
1
1473 return AuthorityPresentAndPathIsRelative;
executed: return AuthorityPresentAndPathIsRelative;
Execution Count:6
6
1474 } -
1475 if (sectionIsPresent & QUrlPrivate::Scheme)
evaluated: sectionIsPresent & QUrlPrivate::Scheme
TRUEFALSE
yes
Evaluation Count:336
yes
Evaluation Count:174
174-336
1476 return NoError;
executed: return NoError;
Execution Count:336
336
1477 -
1478 // check for a path of "text:text/" -
1479 for (int i = 0; i < path.length(); ++i) {
evaluated: i < path.length()
TRUEFALSE
yes
Evaluation Count:1114
yes
Evaluation Count:113
113-1114
1480 register ushort c = path.at(i).unicode();
executed (the execution status of this line is deduced): register ushort c = path.at(i).unicode();
-
1481 if (c == '/') {
evaluated: c == '/'
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:1066
48-1066
1482 // found the slash before the colon -
1483 return NoError;
executed: return NoError;
Execution Count:48
48
1484 } -
1485 if (c == ':') {
evaluated: c == ':'
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:1053
13-1053
1486 // found the colon before the slash, it's invalid -
1487 if (source) {
evaluated: source
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:7
6-7
1488 *source = path;
executed (the execution status of this line is deduced): *source = path;
-
1489 *position = i;
executed (the execution status of this line is deduced): *position = i;
-
1490 }
executed: }
Execution Count:6
6
1491 return RelativeUrlPathContainsColonBeforeSlash;
executed: return RelativeUrlPathContainsColonBeforeSlash;
Execution Count:13
13
1492 } -
1493 }
executed: }
Execution Count:1053
1053
1494 return NoError;
executed: return NoError;
Execution Count:113
113
1495} -
1496 -
1497bool QUrlPrivate::validateComponent(QUrlPrivate::Section section, const QString &input, -
1498 int begin, int end) -
1499{ -
1500 // What we need to look out for, that the regular parser tolerates: -
1501 // - percent signs not followed by two hex digits -
1502 // - forbidden characters, which should always appear encoded -
1503 // '"' / '<' / '>' / '\' / '^' / '`' / '{' / '|' / '}' / BKSP -
1504 // control characters -
1505 // - delimiters not allowed in certain positions -
1506 // . scheme: parser is already strict -
1507 // . user info: gen-delims except ":" disallowed ("/" / "?" / "#" / "[" / "]" / "@") -
1508 // . host: parser is stricter than the standard -
1509 // . port: parser is stricter than the standard -
1510 // . path: all delimiters allowed -
1511 // . fragment: all delimiters allowed -
1512 // . query: all delimiters allowed -
1513 static const char forbidden[] = "\"<>\\^`{|}\x7F"; -
1514 static const char forbiddenUserInfo[] = ":/?#[]@"; -
1515 -
1516 Q_ASSERT(section != Authority && section != Hierarchy && section != FullUrl);
executed (the execution status of this line is deduced): qt_noop();
-
1517 -
1518 const ushort *const data = reinterpret_cast<const ushort *>(input.constData());
executed (the execution status of this line is deduced): const ushort *const data = reinterpret_cast<const ushort *>(input.constData());
-
1519 for (uint i = uint(begin); i < uint(end); ++i) {
evaluated: i < uint(end)
TRUEFALSE
yes
Evaluation Count:3456
yes
Evaluation Count:118
118-3456
1520 register uint uc = data[i];
executed (the execution status of this line is deduced): register uint uc = data[i];
-
1521 if (uc >= 0x80)
partially evaluated: uc >= 0x80
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3456
0-3456
1522 continue;
never executed: continue;
0
1523 -
1524 bool error = false;
executed (the execution status of this line is deduced): bool error = false;
-
1525 if ((uc == '%' && (uint(end) < i + 2 || !isHex(data[i + 1]) || !isHex(data[i + 2])))
evaluated: uc == '%'
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:3431
evaluated: uint(end) < i + 2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
evaluated: !isHex(data[i + 1])
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:19
evaluated: !isHex(data[i + 2])
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:9
1-3431
1526 || uc <= 0x20 || strchr(forbidden, uc)) {
evaluated: uc <= 0x20
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3438
evaluated: strchr(forbidden, uc)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3426
2-3438
1527 // found an error -
1528 error = true;
executed (the execution status of this line is deduced): error = true;
-
1529 } else if (section & UserInfo) {
executed: }
Execution Count:30
evaluated: section & UserInfo
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:3351
30-3351
1530 if (section == UserInfo && strchr(forbiddenUserInfo + 1, uc))
evaluated: section == UserInfo
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:22
evaluated: strchr(forbiddenUserInfo + 1, uc)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:52
1-53
1531 error = true;
executed: error = true;
Execution Count:1
1
1532 else if (section != UserInfo && strchr(forbiddenUserInfo, uc))
evaluated: section != UserInfo
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:52
evaluated: strchr(forbiddenUserInfo, uc)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:18
4-52
1533 error = true;
executed: error = true;
Execution Count:4
4
1534 } -
1535 -
1536 if (!error)
evaluated: !error
TRUEFALSE
yes
Evaluation Count:3421
yes
Evaluation Count:35
35-3421
1537 continue;
executed: continue;
Execution Count:3421
3421
1538 -
1539 ErrorCode errorCode = ErrorCode(int(section) << 8);
executed (the execution status of this line is deduced): ErrorCode errorCode = ErrorCode(int(section) << 8);
-
1540 if (section == UserInfo) {
evaluated: section == UserInfo
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:23
12-23
1541 // is it the user name or the password? -
1542 errorCode = InvalidUserNameError;
executed (the execution status of this line is deduced): errorCode = InvalidUserNameError;
-
1543 for (uint j = uint(begin); j < i; ++j)
evaluated: j < i
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:9
9-41
1544 if (data[j] == ':') {
evaluated: data[j] == ':'
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:38
3-38
1545 errorCode = InvalidPasswordError;
executed (the execution status of this line is deduced): errorCode = InvalidPasswordError;
-
1546 break;
executed: break;
Execution Count:3
3
1547 } -
1548 }
executed: }
Execution Count:12
12
1549 -
1550 setError(errorCode, input, i);
executed (the execution status of this line is deduced): setError(errorCode, input, i);
-
1551 return false;
executed: return false;
Execution Count:35
35
1552 } -
1553 -
1554 // no errors -
1555 return true;
executed: return true;
Execution Count:118
118
1556} -
1557 -
1558#if 0 -
1559inline void QUrlPrivate::validate() const -
1560{ -
1561 QUrlPrivate *that = (QUrlPrivate *)this; -
1562 that->encodedOriginal = that->toEncoded(); // may detach -
1563 parse(ParseOnly); -
1564 -
1565 QURL_SETFLAG(that->stateFlags, Validated); -
1566 -
1567 if (!isValid) -
1568 return; -
1569 -
1570 QString auth = authority(); // causes the non-encoded forms to be valid -
1571 -
1572 // authority() calls canonicalHost() which sets this -
1573 if (!isHostValid) -
1574 return; -
1575 -
1576 if (scheme == QLatin1String("mailto")) { -
1577 if (!host.isEmpty() || port != -1 || !userName.isEmpty() || !password.isEmpty()) { -
1578 that->isValid = false; -
1579 that->errorInfo.setParams(0, QT_TRANSLATE_NOOP(QUrl, "expected empty host, username," -
1580 "port and password"), -
1581 0, 0); -
1582 } -
1583 } else if (scheme == ftpScheme() || scheme == httpScheme()) { -
1584 if (host.isEmpty() && !(path.isEmpty() && encodedPath.isEmpty())) { -
1585 that->isValid = false; -
1586 that->errorInfo.setParams(0, QT_TRANSLATE_NOOP(QUrl, "the host is empty, but not the path"), -
1587 0, 0); -
1588 } -
1589 } -
1590} -
1591 -
1592inline const QByteArray &QUrlPrivate::normalized() const -
1593{ -
1594 if (QURL_HASFLAG(stateFlags, QUrlPrivate::Normalized)) -
1595 return encodedNormalized; -
1596 -
1597 QUrlPrivate *that = const_cast<QUrlPrivate *>(this); -
1598 QURL_SETFLAG(that->stateFlags, QUrlPrivate::Normalized); -
1599 -
1600 QUrlPrivate tmp = *this; -
1601 tmp.scheme = tmp.scheme.toLower(); -
1602 tmp.host = tmp.canonicalHost(); -
1603 -
1604 // ensure the encoded and normalized parts of the URL -
1605 tmp.ensureEncodedParts(); -
1606 if (tmp.encodedUserName.contains('%')) -
1607 q_normalizePercentEncoding(&tmp.encodedUserName, userNameExcludeChars); -
1608 if (tmp.encodedPassword.contains('%')) -
1609 q_normalizePercentEncoding(&tmp.encodedPassword, passwordExcludeChars); -
1610 if (tmp.encodedFragment.contains('%')) -
1611 q_normalizePercentEncoding(&tmp.encodedFragment, fragmentExcludeChars); -
1612 -
1613 if (tmp.encodedPath.contains('%')) { -
1614 // the path is a bit special: -
1615 // the slashes shouldn't be encoded or decoded. -
1616 // They should remain exactly like they are right now -
1617 // -
1618 // treat the path as a slash-separated sequence of pchar -
1619 QByteArray result; -
1620 result.reserve(tmp.encodedPath.length()); -
1621 if (tmp.encodedPath.startsWith('/')) -
1622 result.append('/'); -
1623 -
1624 const char *data = tmp.encodedPath.constData(); -
1625 int lastSlash = 0; -
1626 int nextSlash; -
1627 do { -
1628 ++lastSlash; -
1629 nextSlash = tmp.encodedPath.indexOf('/', lastSlash); -
1630 int len; -
1631 if (nextSlash == -1) -
1632 len = tmp.encodedPath.length() - lastSlash; -
1633 else -
1634 len = nextSlash - lastSlash; -
1635 -
1636 if (memchr(data + lastSlash, '%', len)) { -
1637 // there's at least one percent before the next slash -
1638 QByteArray block = QByteArray(data + lastSlash, len); -
1639 q_normalizePercentEncoding(&block, pathExcludeChars); -
1640 result.append(block); -
1641 } else { -
1642 // no percents in this path segment, append wholesale -
1643 result.append(data + lastSlash, len); -
1644 } -
1645 -
1646 // append the slash too, if it's there -
1647 if (nextSlash != -1) -
1648 result.append('/'); -
1649 -
1650 lastSlash = nextSlash; -
1651 } while (lastSlash != -1); -
1652 -
1653 tmp.encodedPath = result; -
1654 } -
1655 -
1656 if (!tmp.scheme.isEmpty()) // relative test -
1657 removeDotsFromPath(&tmp.encodedPath); -
1658 -
1659 int qLen = tmp.query.length(); -
1660 for (int i = 0; i < qLen; i++) { -
1661 if (qLen - i > 2 && tmp.query.at(i) == '%') { -
1662 ++i; -
1663 tmp.query[i] = qToLower(tmp.query.at(i)); -
1664 ++i; -
1665 tmp.query[i] = qToLower(tmp.query.at(i)); -
1666 } -
1667 } -
1668 encodedNormalized = tmp.toEncoded(); -
1669 -
1670 return encodedNormalized; -
1671} -
1672#endif -
1673 -
1674/*! -
1675 \macro QT_NO_URL_CAST_FROM_STRING -
1676 \relates QUrl -
1677 -
1678 Disables automatic conversions from QString (or char *) to QUrl. -
1679 -
1680 Compiling your code with this define is useful when you have a lot of -
1681 code that uses QString for file names and you wish to convert it to -
1682 use QUrl for network transparency. In any code that uses QUrl, it can -
1683 help avoid missing QUrl::resolved() calls, and other misuses of -
1684 QString to QUrl conversions. -
1685 -
1686 \oldcode -
1687 url = filename; // probably not what you want -
1688 \newcode -
1689 url = QUrl::fromLocalFile(filename); -
1690 url = baseurl.resolved(QUrl(filename)); -
1691 \endcode -
1692 -
1693 \sa QT_NO_CAST_FROM_ASCII -
1694*/ -
1695 -
1696 -
1697/*! -
1698 Constructs a URL by parsing \a url. QUrl will automatically percent encode -
1699 all characters that are not allowed in a URL and decode the percent-encoded -
1700 sequences that represent a character that is allowed in a URL. -
1701 -
1702 Parses the \a url using the parser mode \a parsingMode. In TolerantMode -
1703 (the default), QUrl will correct certain mistakes, notably the presence of -
1704 a percent character ('%') not followed by two hexadecimal digits, and it -
1705 will accept any character in any position. In StrictMode, encoding mistakes -
1706 will not be tolerated and QUrl will also check that certain forbidden -
1707 characters are not present in unencoded form. If an error is detected in -
1708 StrictMode, isValid() will return false. The parsing mode DecodedMode is not -
1709 permitted in this context. -
1710 -
1711 Example: -
1712 -
1713 \snippet code/src_corelib_io_qurl.cpp 0 -
1714 -
1715 To construct a URL from an encoded string, you can also use fromEncoded(): -
1716 -
1717 \snippet code/src_corelib_io_qurl.cpp 1 -
1718 -
1719 Both functions are equivalent and, in Qt 5, both functions accept encoded -
1720 data. Usually, the choice of the QUrl constructor or setUrl() versus -
1721 fromEncoded() will depend on the source data: the constructor and setUrl() -
1722 take a QString, whereas fromEncoded takes a QByteArray. -
1723 -
1724 \sa setUrl(), fromEncoded(), TolerantMode -
1725*/ -
1726QUrl::QUrl(const QString &url, ParsingMode parsingMode) : d(0) -
1727{ -
1728 setUrl(url, parsingMode);
executed (the execution status of this line is deduced): setUrl(url, parsingMode);
-
1729}
executed: }
Execution Count:6414
6414
1730 -
1731/*! -
1732 Constructs an empty QUrl object. -
1733*/ -
1734QUrl::QUrl() : d(0) -
1735{ -
1736}
executed: }
Execution Count:23169
23169
1737 -
1738/*! -
1739 Constructs a copy of \a other. -
1740*/ -
1741QUrl::QUrl(const QUrl &other) : d(other.d) -
1742{ -
1743 if (d)
evaluated: d
TRUEFALSE
yes
Evaluation Count:39982
yes
Evaluation Count:6172
6172-39982
1744 d->ref.ref();
executed: d->ref.ref();
Execution Count:39979
39979
1745}
executed: }
Execution Count:46180
46180
1746 -
1747/*! -
1748 Destructor; called immediately before the object is deleted. -
1749*/ -
1750QUrl::~QUrl() -
1751{ -
1752 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:59462
yes
Evaluation Count:20714
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:22757
yes
Evaluation Count:36755
20714-59462
1753 delete d;
executed: delete d;
Execution Count:22736
22736
1754}
executed: }
Execution Count:80171
80171
1755 -
1756/*! -
1757 Returns true if the URL is non-empty and valid; otherwise returns false. -
1758 -
1759 The URL is run through a conformance test. Every part of the URL -
1760 must conform to the standard encoding rules of the URI standard -
1761 for the URL to be reported as valid. -
1762 -
1763 \snippet code/src_corelib_io_qurl.cpp 2 -
1764*/ -
1765bool QUrl::isValid() const -
1766{ -
1767 if (isEmpty()) {
evaluated: isEmpty()
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:10835
73-10835
1768 // also catches d == 0 -
1769 return false;
executed: return false;
Execution Count:73
73
1770 } -
1771 return d->validityError() == QUrlPrivate::NoError;
executed: return d->validityError() == QUrlPrivate::NoError;
Execution Count:10835
10835
1772} -
1773 -
1774/*! -
1775 Returns true if the URL has no data; otherwise returns false. -
1776 -
1777 \sa clear() -
1778*/ -
1779bool QUrl::isEmpty() const -
1780{ -
1781 if (!d) return true;
executed: return true;
Execution Count:154
evaluated: !d
TRUEFALSE
yes
Evaluation Count:154
yes
Evaluation Count:10926
154-10926
1782 return d->isEmpty();
executed: return d->isEmpty();
Execution Count:10924
10924
1783} -
1784 -
1785/*! -
1786 Resets the content of the QUrl. After calling this function, the -
1787 QUrl is equal to one that has been constructed with the default -
1788 empty constructor. -
1789 -
1790 \sa isEmpty() -
1791*/ -
1792void QUrl::clear() -
1793{ -
1794 if (d && !d->ref.deref())
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1795 delete d;
executed: delete d;
Execution Count:1
1
1796 d = 0;
executed (the execution status of this line is deduced): d = 0;
-
1797}
executed: }
Execution Count:1
1
1798 -
1799/*! -
1800 Parses \a url and sets this object to that value. QUrl will automatically -
1801 percent encode all characters that are not allowed in a URL and decode the -
1802 percent-encoded sequences that represent a character that is allowed in a -
1803 URL. -
1804 -
1805 Parses the \a url using the parser mode \a parsingMode. In TolerantMode -
1806 (the default), QUrl will correct certain mistakes, notably the presence of -
1807 a percent character ('%') not followed by two hexadecimal digits, and it -
1808 will accept any character in any position. In StrictMode, encoding mistakes -
1809 will not be tolerated and QUrl will also check that certain forbidden -
1810 characters are not present in unencoded form. If an error is detected in -
1811 StrictMode, isValid() will return false. The parsing mode DecodedMode is -
1812 not permitted in this context and will produce a run-time warning. -
1813 -
1814 \sa url(), toString() -
1815*/ -
1816void QUrl::setUrl(const QString &url, ParsingMode parsingMode) -
1817{ -
1818 if (parsingMode == DecodedMode) {
partially evaluated: parsingMode == DecodedMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7806
0-7806
1819 qWarning("QUrl: QUrl::DecodedMode is not permitted when parsing a full URL");
never executed (the execution status of this line is deduced): QMessageLogger("io/qurl.cpp", 1819, __PRETTY_FUNCTION__).warning("QUrl: QUrl::DecodedMode is not permitted when parsing a full URL");
-
1820 } else {
never executed: }
0
1821 detach();
executed (the execution status of this line is deduced): detach();
-
1822 d->parse(url, parsingMode);
executed (the execution status of this line is deduced): d->parse(url, parsingMode);
-
1823 }
executed: }
Execution Count:7788
7788
1824} -
1825 -
1826/*! -
1827 \fn void QUrl::setEncodedUrl(const QByteArray &encodedUrl, ParsingMode parsingMode) -
1828 \deprecated -
1829 Constructs a URL by parsing the contents of \a encodedUrl. -
1830 -
1831 \a encodedUrl is assumed to be a URL string in percent encoded -
1832 form, containing only ASCII characters. -
1833 -
1834 The parsing mode \a parsingMode is used for parsing \a encodedUrl. -
1835 -
1836 \obsolete Use setUrl(QString::fromUtf8(encodedUrl), parsingMode) -
1837 -
1838 \sa setUrl() -
1839*/ -
1840 -
1841/*! -
1842 Sets the scheme of the URL to \a scheme. As a scheme can only -
1843 contain ASCII characters, no conversion or decoding is done on the -
1844 input. It must also start with an ASCII letter. -
1845 -
1846 The scheme describes the type (or protocol) of the URL. It's -
1847 represented by one or more ASCII characters at the start the URL, -
1848 and is followed by a ':'. The following example shows a URL where -
1849 the scheme is "ftp": -
1850 -
1851 \image qurl-authority2.png -
1852 -
1853 The scheme can also be empty, in which case the URL is interpreted -
1854 as relative. -
1855 -
1856 \sa scheme(), isRelative() -
1857*/ -
1858void QUrl::setScheme(const QString &scheme) -
1859{ -
1860 detach();
executed (the execution status of this line is deduced): detach();
-
1861 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
1862 if (scheme.isEmpty()) {
evaluated: scheme.isEmpty()
TRUEFALSE
yes
Evaluation Count:2088
yes
Evaluation Count:2417
2088-2417
1863 // schemes are not allowed to be empty -
1864 d->sectionIsPresent &= ~QUrlPrivate::Scheme;
executed (the execution status of this line is deduced): d->sectionIsPresent &= ~QUrlPrivate::Scheme;
-
1865 d->scheme.clear();
executed (the execution status of this line is deduced): d->scheme.clear();
-
1866 } else {
executed: }
Execution Count:2088
2088
1867 d->setScheme(scheme, scheme.length(), /* do set error */ true);
executed (the execution status of this line is deduced): d->setScheme(scheme, scheme.length(), true);
-
1868 }
executed: }
Execution Count:2417
2417
1869} -
1870 -
1871/*! -
1872 Returns the scheme of the URL. If an empty string is returned, -
1873 this means the scheme is undefined and the URL is then relative. -
1874 -
1875 The scheme can only contain US-ASCII letters or digits, which means it -
1876 cannot contain any character that would otherwise require encoding. -
1877 -
1878 \sa setScheme(), isRelative() -
1879*/ -
1880QString QUrl::scheme() const -
1881{ -
1882 if (!d) return QString();
executed: return QString();
Execution Count:1
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5879
1-5879
1883 -
1884 return d->scheme;
executed: return d->scheme;
Execution Count:5877
5877
1885} -
1886 -
1887/*! -
1888 Sets the authority of the URL to \a authority. -
1889 -
1890 The authority of a URL is the combination of user info, a host -
1891 name and a port. All of these elements are optional; an empty -
1892 authority is therefore valid. -
1893 -
1894 The user info and host are separated by a '@', and the host and -
1895 port are separated by a ':'. If the user info is empty, the '@' -
1896 must be omitted; although a stray ':' is permitted if the port is -
1897 empty. -
1898 -
1899 The following example shows a valid authority string: -
1900 -
1901 \image qurl-authority.png -
1902 -
1903 The \a authority data is interpreted according to \a mode: in StrictMode, -
1904 any '%' characters must be followed by exactly two hexadecimal characters -
1905 and some characters (including space) are not allowed in undecoded form. In -
1906 TolerantMode (the default), all characters are accepted in undecoded form -
1907 and the tolerant parser will correct stray '%' not followed by two hex -
1908 characters. In DecodedMode, '%' stand for themselves and encoded characters -
1909 are not possible. Because of that, in DecodedMode, it is not possible to -
1910 use the delimiter characters as non-delimiters (e.g., a password containing -
1911 a '@'). -
1912 -
1913 \sa setUserInfo(), setHost(), setPort() -
1914*/ -
1915void QUrl::setAuthority(const QString &authority, ParsingMode mode) -
1916{ -
1917 detach();
executed (the execution status of this line is deduced): detach();
-
1918 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
1919 QString data = authority;
executed (the execution status of this line is deduced): QString data = authority;
-
1920 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:20
1-20
1921 parseDecodedComponent(data);
executed (the execution status of this line is deduced): parseDecodedComponent(data);
-
1922 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
1923 }
executed: }
Execution Count:1
1
1924 -
1925 d->setAuthority(data, 0, data.length(), mode);
executed (the execution status of this line is deduced): d->setAuthority(data, 0, data.length(), mode);
-
1926 if (authority.isNull()) {
evaluated: authority.isNull()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:18
3-18
1927 // QUrlPrivate::setAuthority cleared almost everything -
1928 // but it leaves the Host bit set -
1929 d->sectionIsPresent &= ~QUrlPrivate::Authority;
executed (the execution status of this line is deduced): d->sectionIsPresent &= ~QUrlPrivate::Authority;
-
1930 }
executed: }
Execution Count:3
3
1931}
executed: }
Execution Count:21
21
1932 -
1933/*! -
1934 Returns the authority of the URL if it is defined; otherwise -
1935 an empty string is returned. -
1936 -
1937 The \a options argument controls how to format the authority portion of the -
1938 URL. The value of QUrl::FullyDecoded should be avoided, since it may -
1939 produce an ambiguous return value (for example, if the username contains a -
1940 colon ':' or either the username or password contain an at-sign '@'). In -
1941 all other cases, this function returns an unambiguous value, which may -
1942 contain those characters still percent-encoded, plus some control -
1943 sequences not representable in decoded form in QString. -
1944 -
1945 \sa setAuthority(), userInfo(), userName(), password(), host(), port() -
1946*/ -
1947QString QUrl::authority(ComponentFormattingOptions options) const -
1948{ -
1949 if (!d) return QString();
executed: return QString();
Execution Count:1
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:70
1-70
1950 -
1951 QString result;
executed (the execution status of this line is deduced): QString result;
-
1952 d->appendAuthority(result, options, QUrlPrivate::Authority);
executed (the execution status of this line is deduced): d->appendAuthority(result, options, QUrlPrivate::Authority);
-
1953 return result;
executed: return result;
Execution Count:70
70
1954} -
1955 -
1956/*! -
1957 Sets the user info of the URL to \a userInfo. The user info is an -
1958 optional part of the authority of the URL, as described in -
1959 setAuthority(). -
1960 -
1961 The user info consists of a user name and optionally a password, -
1962 separated by a ':'. If the password is empty, the colon must be -
1963 omitted. The following example shows a valid user info string: -
1964 -
1965 \image qurl-authority3.png -
1966 -
1967 The \a userInfo data is interpreted according to \a mode: in StrictMode, -
1968 any '%' characters must be followed by exactly two hexadecimal characters -
1969 and some characters (including space) are not allowed in undecoded form. In -
1970 TolerantMode (the default), all characters are accepted in undecoded form -
1971 and the tolerant parser will correct stray '%' not followed by two hex -
1972 characters. In DecodedMode, '%' stand for themselves and encoded characters -
1973 are not possible. Because of that, in DecodedMode, it is not possible to -
1974 use the ':' delimiter characters as non-delimiter in the user name. -
1975 -
1976 \sa userInfo(), setUserName(), setPassword(), setAuthority() -
1977*/ -
1978void QUrl::setUserInfo(const QString &userInfo, ParsingMode mode) -
1979{ -
1980 detach();
executed (the execution status of this line is deduced): detach();
-
1981 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
1982 QString trimmed = userInfo.trimmed();
executed (the execution status of this line is deduced): QString trimmed = userInfo.trimmed();
-
1983 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:45
1-45
1984 parseDecodedComponent(trimmed);
executed (the execution status of this line is deduced): parseDecodedComponent(trimmed);
-
1985 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
1986 }
executed: }
Execution Count:1
1
1987 -
1988 d->setUserInfo(trimmed, 0, trimmed.length());
executed (the execution status of this line is deduced): d->setUserInfo(trimmed, 0, trimmed.length());
-
1989 if (userInfo.isNull()) {
evaluated: userInfo.isNull()
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:10
10-36
1990 // QUrlPrivate::setUserInfo cleared almost everything -
1991 // but it leaves the UserName bit set -
1992 d->sectionIsPresent &= ~QUrlPrivate::UserInfo;
executed (the execution status of this line is deduced): d->sectionIsPresent &= ~QUrlPrivate::UserInfo;
-
1993 } else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::UserInfo, userInfo)) {
executed: }
Execution Count:36
evaluated: mode == StrictMode
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
partially evaluated: !d->validateComponent(QUrlPrivate::UserInfo, userInfo)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-36
1994 d->sectionIsPresent &= ~QUrlPrivate::UserInfo;
executed (the execution status of this line is deduced): d->sectionIsPresent &= ~QUrlPrivate::UserInfo;
-
1995 d->userName.clear();
executed (the execution status of this line is deduced): d->userName.clear();
-
1996 d->password.clear();
executed (the execution status of this line is deduced): d->password.clear();
-
1997 }
executed: }
Execution Count:5
5
1998} -
1999 -
2000/*! -
2001 Returns the user info of the URL, or an empty string if the user -
2002 info is undefined. -
2003 -
2004 The \a options argument controls how to format the user info component. The -
2005 value of QUrl::FullyDecoded should be avoided, since it may produce an -
2006 ambiguous return value (for example, if the username contains a colon ':'). -
2007 In all other cases, this function returns an unambiguous value, which may -
2008 contain that characters still percent-encoded, plus some control sequences -
2009 not representable in decoded form in QString. -
2010 -
2011 \sa setUserInfo(), userName(), password(), authority() -
2012*/ -
2013QString QUrl::userInfo(ComponentFormattingOptions options) const -
2014{ -
2015 if (!d) return QString();
executed: return QString();
Execution Count:1
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1025
1-1025
2016 -
2017 QString result;
executed (the execution status of this line is deduced): QString result;
-
2018 d->appendUserInfo(result, options, QUrlPrivate::UserInfo);
executed (the execution status of this line is deduced): d->appendUserInfo(result, options, QUrlPrivate::UserInfo);
-
2019 return result;
executed: return result;
Execution Count:1025
1025
2020} -
2021 -
2022/*! -
2023 Sets the URL's user name to \a userName. The \a userName is part -
2024 of the user info element in the authority of the URL, as described -
2025 in setUserInfo(). -
2026 -
2027 The \a userName data is interpreted according to \a mode: in StrictMode, -
2028 any '%' characters must be followed by exactly two hexadecimal characters -
2029 and some characters (including space) are not allowed in undecoded form. In -
2030 TolerantMode (the default), all characters are accepted in undecoded form -
2031 and the tolerant parser will correct stray '%' not followed by two hex -
2032 characters. In DecodedMode, '%' stand for themselves and encoded characters -
2033 are not possible. -
2034 -
2035 QUrl::DecodedMode should be used when setting the user name from a data -
2036 source which is not a URL, such as a password dialog shown to the user or -
2037 with a user name obtained by calling userName() with the QUrl::FullyDecoded -
2038 formatting option. -
2039 -
2040 \sa userName(), setUserInfo() -
2041*/ -
2042void QUrl::setUserName(const QString &userName, ParsingMode mode) -
2043{ -
2044 detach();
executed (the execution status of this line is deduced): detach();
-
2045 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2046 -
2047 QString data = userName;
executed (the execution status of this line is deduced): QString data = userName;
-
2048 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1855
1-1855
2049 parseDecodedComponent(data);
executed (the execution status of this line is deduced): parseDecodedComponent(data);
-
2050 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
2051 }
executed: }
Execution Count:1
1
2052 -
2053 d->setUserName(data, 0, data.length());
executed (the execution status of this line is deduced): d->setUserName(data, 0, data.length());
-
2054 if (userName.isNull())
evaluated: userName.isNull()
TRUEFALSE
yes
Evaluation Count:499
yes
Evaluation Count:1340
499-1340
2055 d->sectionIsPresent &= ~QUrlPrivate::UserName;
executed: d->sectionIsPresent &= ~QUrlPrivate::UserName;
Execution Count:499
499
2056 else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::UserName, userName))
evaluated: mode == StrictMode
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1334
partially evaluated: !d->validateComponent(QUrlPrivate::UserName, userName)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-1334
2057 d->userName.clear();
executed: d->userName.clear();
Execution Count:4
4
2058} -
2059 -
2060/*! -
2061 Returns the user name of the URL if it is defined; otherwise -
2062 an empty string is returned. -
2063 -
2064 The \a options argument controls how to format the user name component. All -
2065 values produce an unambiguous result. With QUrl::FullyDecoded, all -
2066 percent-encoded sequences are decoded; otherwise, the returned value may -
2067 contain some percent-encoded sequences for some control sequences not -
2068 representable in decoded form in QString. -
2069 -
2070 Note that QUrl::FullyDecoded may cause data loss if those non-representable -
2071 sequences are present. It is recommended to use that value when the result -
2072 will be used in a non-URL context, such as setting in QAuthenticator or -
2073 negotiating a login. -
2074 -
2075 \sa setUserName(), userInfo() -
2076*/ -
2077QString QUrl::userName(ComponentFormattingOptions options) const -
2078{ -
2079 if (!d) return QString();
executed: return QString();
Execution Count:2
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:752
2-752
2080 -
2081 QString result;
executed (the execution status of this line is deduced): QString result;
-
2082 d->appendUserName(result, options);
executed (the execution status of this line is deduced): d->appendUserName(result, options);
-
2083 return result;
executed: return result;
Execution Count:752
752
2084} -
2085 -
2086/*! -
2087 \fn void QUrl::setEncodedUserName(const QByteArray &userName) -
2088 \deprecated -
2089 \since 4.4 -
2090 -
2091 Sets the URL's user name to the percent-encoded \a userName. The \a -
2092 userName is part of the user info element in the authority of the -
2093 URL, as described in setUserInfo(). -
2094 -
2095 \obsolete Use setUserName(QString::fromUtf8(userName)) -
2096 -
2097 \sa setUserName(), encodedUserName(), setUserInfo() -
2098*/ -
2099 -
2100/*! -
2101 \fn QByteArray QUrl::encodedUserName() const -
2102 \deprecated -
2103 \since 4.4 -
2104 -
2105 Returns the user name of the URL if it is defined; otherwise -
2106 an empty string is returned. The returned value will have its -
2107 non-ASCII and other control characters percent-encoded, as in -
2108 toEncoded(). -
2109 -
2110 \obsolete Use userName(QUrl::FullyEncoded).toLatin1() -
2111 -
2112 \sa setEncodedUserName() -
2113*/ -
2114 -
2115/*! -
2116 Sets the URL's password to \a password. The \a password is part of -
2117 the user info element in the authority of the URL, as described in -
2118 setUserInfo(). -
2119 -
2120 The \a password data is interpreted according to \a mode: in StrictMode, -
2121 any '%' characters must be followed by exactly two hexadecimal characters -
2122 and some characters (including space) are not allowed in undecoded form. In -
2123 TolerantMode, all characters are accepted in undecoded form and the -
2124 tolerant parser will correct stray '%' not followed by two hex characters. -
2125 In DecodedMode, '%' stand for themselves and encoded characters are not -
2126 possible. -
2127 -
2128 QUrl::DecodedMode should be used when setting the password from a data -
2129 source which is not a URL, such as a password dialog shown to the user or -
2130 with a password obtained by calling password() with the QUrl::FullyDecoded -
2131 formatting option. -
2132 -
2133 \sa password(), setUserInfo() -
2134*/ -
2135void QUrl::setPassword(const QString &password, ParsingMode mode) -
2136{ -
2137 detach();
executed (the execution status of this line is deduced): detach();
-
2138 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2139 -
2140 QString data = password;
executed (the execution status of this line is deduced): QString data = password;
-
2141 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:432
1-432
2142 parseDecodedComponent(data);
executed (the execution status of this line is deduced): parseDecodedComponent(data);
-
2143 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
2144 }
executed: }
Execution Count:1
1
2145 -
2146 d->setPassword(data, 0, data.length());
executed (the execution status of this line is deduced): d->setPassword(data, 0, data.length());
-
2147 if (password.isNull())
evaluated: password.isNull()
TRUEFALSE
yes
Evaluation Count:418
yes
Evaluation Count:15
15-418
2148 d->sectionIsPresent &= ~QUrlPrivate::Password;
executed: d->sectionIsPresent &= ~QUrlPrivate::Password;
Execution Count:418
418
2149 else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::Password, password))
evaluated: mode == StrictMode
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:11
partially evaluated: !d->validateComponent(QUrlPrivate::Password, password)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-11
2150 d->password.clear();
executed: d->password.clear();
Execution Count:4
4
2151} -
2152 -
2153/*! -
2154 Returns the password of the URL if it is defined; otherwise -
2155 an empty string is returned. -
2156 -
2157 The \a options argument controls how to format the user name component. All -
2158 values produce an unambiguous result. With QUrl::FullyDecoded, all -
2159 percent-encoded sequences are decoded; otherwise, the returned value may -
2160 contain some percent-encoded sequences for some control sequences not -
2161 representable in decoded form in QString. -
2162 -
2163 Note that QUrl::FullyDecoded may cause data loss if those non-representable -
2164 sequences are present. It is recommended to use that value when the result -
2165 will be used in a non-URL context, such as setting in QAuthenticator or -
2166 negotiating a login. -
2167 -
2168 \sa setPassword() -
2169*/ -
2170QString QUrl::password(ComponentFormattingOptions options) const -
2171{ -
2172 if (!d) return QString();
executed: return QString();
Execution Count:2
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:239
2-239
2173 -
2174 QString result;
executed (the execution status of this line is deduced): QString result;
-
2175 d->appendPassword(result, options);
executed (the execution status of this line is deduced): d->appendPassword(result, options);
-
2176 return result;
executed: return result;
Execution Count:239
239
2177} -
2178 -
2179/*! -
2180 \fn void QUrl::setEncodedPassword(const QByteArray &password) -
2181 \deprecated -
2182 \since 4.4 -
2183 -
2184 Sets the URL's password to the percent-encoded \a password. The \a -
2185 password is part of the user info element in the authority of the -
2186 URL, as described in setUserInfo(). -
2187 -
2188 \obsolete Use setPassword(QString::fromUtf8(password)); -
2189 -
2190 \sa setPassword(), encodedPassword(), setUserInfo() -
2191*/ -
2192 -
2193/*! -
2194 \fn QByteArray QUrl::encodedPassword() const -
2195 \deprecated -
2196 \since 4.4 -
2197 -
2198 Returns the password of the URL if it is defined; otherwise an -
2199 empty string is returned. The returned value will have its -
2200 non-ASCII and other control characters percent-encoded, as in -
2201 toEncoded(). -
2202 -
2203 \obsolete Use password(QUrl::FullyEncoded).toLatin1() -
2204 -
2205 \sa setEncodedPassword(), toEncoded() -
2206*/ -
2207 -
2208/*! -
2209 Sets the host of the URL to \a host. The host is part of the -
2210 authority. -
2211 -
2212 The \a host data is interpreted according to \a mode: in StrictMode, -
2213 any '%' characters must be followed by exactly two hexadecimal characters -
2214 and some characters (including space) are not allowed in undecoded form. In -
2215 TolerantMode, all characters are accepted in undecoded form and the -
2216 tolerant parser will correct stray '%' not followed by two hex characters. -
2217 In DecodedMode, '%' stand for themselves and encoded characters are not -
2218 possible. -
2219 -
2220 Note that, in all cases, the result of the parsing must be a valid hostname -
2221 according to STD 3 rules, as modified by the Internationalized Resource -
2222 Identifiers specification (RFC 3987). Invalid hostnames are not permitted -
2223 and will cause isValid() to become false. -
2224 -
2225 \sa host(), setAuthority() -
2226*/ -
2227void QUrl::setHost(const QString &host, ParsingMode mode) -
2228{ -
2229 detach();
executed (the execution status of this line is deduced): detach();
-
2230 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2231 -
2232 QString data = host;
executed (the execution status of this line is deduced): QString data = host;
-
2233 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3016
1-3016
2234 parseDecodedComponent(data);
executed (the execution status of this line is deduced): parseDecodedComponent(data);
-
2235 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
2236 }
executed: }
Execution Count:1
1
2237 -
2238 if (d->setHost(data, 0, data.length(), mode)) {
evaluated: d->setHost(data, 0, data.length(), mode)
TRUEFALSE
yes
Evaluation Count:2963
yes
Evaluation Count:43
43-2963
2239 if (host.isNull())
evaluated: host.isNull()
TRUEFALSE
yes
Evaluation Count:173
yes
Evaluation Count:2791
173-2791
2240 d->sectionIsPresent &= ~QUrlPrivate::Host;
executed: d->sectionIsPresent &= ~QUrlPrivate::Host;
Execution Count:173
173
2241 } else if (!data.startsWith(QLatin1Char('['))) {
executed: }
Execution Count:2960
partially evaluated: !data.startsWith(QLatin1Char('['))
TRUEFALSE
yes
Evaluation Count:43
no
Evaluation Count:0
0-2960
2242 // setHost failed, it might be IPv6 or IPvFuture in need of bracketing -
2243 Q_ASSERT(d->error);
executed (the execution status of this line is deduced): qt_noop();
-
2244 -
2245 data.prepend(QLatin1Char('['));
executed (the execution status of this line is deduced): data.prepend(QLatin1Char('['));
-
2246 data.append(QLatin1Char(']'));
executed (the execution status of this line is deduced): data.append(QLatin1Char(']'));
-
2247 if (!d->setHost(data, 0, data.length(), mode)) {
evaluated: !d->setHost(data, 0, data.length(), mode)
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:28
15-28
2248 // failed again -
2249 if (data.contains(QLatin1Char(':'))) {
evaluated: data.contains(QLatin1Char(':'))
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:6
6-9
2250 // source data contains ':', so it's an IPv6 error -
2251 d->error->code = QUrlPrivate::InvalidIPv6AddressError;
executed (the execution status of this line is deduced): d->error->code = QUrlPrivate::InvalidIPv6AddressError;
-
2252 }
executed: }
Execution Count:9
9
2253 } else {
executed: }
Execution Count:15
15
2254 // succeeded -
2255 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2256 }
executed: }
Execution Count:28
28
2257 } -
2258} -
2259 -
2260/*! -
2261 Returns the host of the URL if it is defined; otherwise -
2262 an empty string is returned. -
2263 -
2264 The \a options argument controls how the hostname will be formatted. The -
2265 QUrl::EncodeUnicode option will cause this function to return the hostname -
2266 in the ASCII-Compatible Encoding (ACE) form, which is suitable for use in -
2267 channels that are not 8-bit clean or that require the legacy hostname (such -
2268 as DNS requests or in HTTP request headers). If that flag is not present, -
2269 this function returns the International Domain Name (IDN) in Unicode form, -
2270 according to the list of permissible top-level domains (see -
2271 idnWhiteList()). -
2272 -
2273 All other flags are ignored. Host names cannot contain control or percent -
2274 characters, so the returned value can be considered fully decoded. -
2275 -
2276 \sa setHost(), idnWhitelist(), setIdnWhitelist(), authority() -
2277*/ -
2278QString QUrl::host(ComponentFormattingOptions options) const -
2279{ -
2280 if (!d) return QString();
executed: return QString();
Execution Count:857
evaluated: !d
TRUEFALSE
yes
Evaluation Count:857
yes
Evaluation Count:4630
857-4630
2281 -
2282 QString result;
executed (the execution status of this line is deduced): QString result;
-
2283 d->appendHost(result, options);
executed (the execution status of this line is deduced): d->appendHost(result, options);
-
2284 if (result.startsWith(QLatin1Char('[')))
evaluated: result.startsWith(QLatin1Char('['))
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:4586
44-4586
2285 return result.mid(1, result.length() - 2);
executed: return result.mid(1, result.length() - 2);
Execution Count:44
44
2286 return result;
executed: return result;
Execution Count:4586
4586
2287} -
2288 -
2289/*! -
2290 \fn void QUrl::setEncodedHost(const QByteArray &host) -
2291 \deprecated -
2292 \since 4.4 -
2293 -
2294 Sets the URL's host to the ACE- or percent-encoded \a host. The \a -
2295 host is part of the user info element in the authority of the -
2296 URL, as described in setAuthority(). -
2297 -
2298 \obsolete Use setHost(QString::fromUtf8(host)). -
2299 -
2300 \sa setHost(), encodedHost(), setAuthority(), fromAce() -
2301*/ -
2302 -
2303/*! -
2304 \fn QByteArray QUrl::encodedHost() const -
2305 \deprecated -
2306 \since 4.4 -
2307 -
2308 Returns the host part of the URL if it is defined; otherwise -
2309 an empty string is returned. -
2310 -
2311 Note: encodedHost() does not return percent-encoded hostnames. Instead, -
2312 the ACE-encoded (bare ASCII in Punycode encoding) form will be -
2313 returned for any non-ASCII hostname. -
2314 -
2315 This function is equivalent to calling QUrl::toAce() on the return -
2316 value of host(). -
2317 -
2318 \obsolete Use host(QUrl::FullyEncoded).toLatin1() or toAce(host()). -
2319 -
2320 \sa setEncodedHost() -
2321*/ -
2322 -
2323/*! -
2324 Sets the port of the URL to \a port. The port is part of the -
2325 authority of the URL, as described in setAuthority(). -
2326 -
2327 \a port must be between 0 and 65535 inclusive. Setting the -
2328 port to -1 indicates that the port is unspecified. -
2329*/ -
2330void QUrl::setPort(int port) -
2331{ -
2332 detach();
executed (the execution status of this line is deduced): detach();
-
2333 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2334 -
2335 if (port < -1 || port > 65535) {
evaluated: port < -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3453
evaluated: port > 65535
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3451
1-3453
2336 port = -1;
executed (the execution status of this line is deduced): port = -1;
-
2337 d->setError(QUrlPrivate::InvalidPortError, QString::number(port), 0);
executed (the execution status of this line is deduced): d->setError(QUrlPrivate::InvalidPortError, QString::number(port), 0);
-
2338 }
executed: }
Execution Count:3
3
2339 -
2340 d->port = port;
executed (the execution status of this line is deduced): d->port = port;
-
2341}
executed: }
Execution Count:3454
3454
2342 -
2343/*! -
2344 \since 4.1 -
2345 -
2346 Returns the port of the URL, or \a defaultPort if the port is -
2347 unspecified. -
2348 -
2349 Example: -
2350 -
2351 \snippet code/src_corelib_io_qurl.cpp 3 -
2352*/ -
2353int QUrl::port(int defaultPort) const -
2354{ -
2355 if (!d) return defaultPort;
executed: return defaultPort;
Execution Count:1
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2721
1-2721
2356 return d->port == -1 ? defaultPort : d->port;
executed: return d->port == -1 ? defaultPort : d->port;
Execution Count:2721
2721
2357} -
2358 -
2359/*! -
2360 Sets the path of the URL to \a path. The path is the part of the -
2361 URL that comes after the authority but before the query string. -
2362 -
2363 \image qurl-ftppath.png -
2364 -
2365 For non-hierarchical schemes, the path will be everything -
2366 following the scheme declaration, as in the following example: -
2367 -
2368 \image qurl-mailtopath.png -
2369 -
2370 The \a path data is interpreted according to \a mode: in StrictMode, -
2371 any '%' characters must be followed by exactly two hexadecimal characters -
2372 and some characters (including space) are not allowed in undecoded form. In -
2373 TolerantMode (the default), all characters are accepted in undecoded form and the -
2374 tolerant parser will correct stray '%' not followed by two hex characters. -
2375 In DecodedMode, '%' stand for themselves and encoded characters are not -
2376 possible. -
2377 -
2378 QUrl::DecodedMode should be used when setting the path from a data source -
2379 which is not a URL, such as a dialog shown to the user or with a path -
2380 obtained by calling path() with the QUrl::FullyDecoded formatting option. -
2381 -
2382 \sa path() -
2383*/ -
2384void QUrl::setPath(const QString &path, ParsingMode mode) -
2385{ -
2386 detach();
executed (the execution status of this line is deduced): detach();
-
2387 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2388 -
2389 QString data = path;
executed (the execution status of this line is deduced): QString data = path;
-
2390 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:2040
yes
Evaluation Count:255
255-2040
2391 parseDecodedComponent(data);
executed (the execution status of this line is deduced): parseDecodedComponent(data);
-
2392 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
2393 }
executed: }
Execution Count:2040
2040
2394 -
2395 d->setPath(data, 0, data.length());
executed (the execution status of this line is deduced): d->setPath(data, 0, data.length());
-
2396 -
2397 // optimized out, since there is no path delimiter -
2398// if (path.isNull()) -
2399// d->sectionIsPresent &= ~QUrlPrivate::Path; -
2400// else -
2401 if (mode == StrictMode && !d->validateComponent(QUrlPrivate::Path, path))
evaluated: mode == StrictMode
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2291
evaluated: !d->validateComponent(QUrlPrivate::Path, path)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2-2291
2402 d->path.clear();
executed: d->path.clear();
Execution Count:2
2
2403}
executed: }
Execution Count:2295
2295
2404 -
2405/*! -
2406 Returns the path of the URL. -
2407 -
2408 The \a options argument controls how to format the path component. All -
2409 values produce an unambiguous result. With QUrl::FullyDecoded, all -
2410 percent-encoded sequences are decoded; otherwise, the returned value may -
2411 contain some percent-encoded sequences for some control sequences not -
2412 representable in decoded form in QString. -
2413 -
2414 Note that QUrl::FullyDecoded may cause data loss if those non-representable -
2415 sequences are present. It is recommended to use that value when the result -
2416 will be used in a non-URL context, such as sending to an FTP server. -
2417 -
2418 \sa setPath() -
2419*/ -
2420QString QUrl::path(ComponentFormattingOptions options) const -
2421{ -
2422 if (!d) return QString();
executed: return QString();
Execution Count:7
evaluated: !d
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:9172
7-9172
2423 -
2424 QString result;
executed (the execution status of this line is deduced): QString result;
-
2425 d->appendPath(result, options, QUrlPrivate::Path);
executed (the execution status of this line is deduced): d->appendPath(result, options, QUrlPrivate::Path);
-
2426 return result;
executed: return result;
Execution Count:9172
9172
2427} -
2428 -
2429/*! -
2430 \fn void QUrl::setEncodedPath(const QByteArray &path) -
2431 \deprecated -
2432 \since 4.4 -
2433 -
2434 Sets the URL's path to the percent-encoded \a path. The path is -
2435 the part of the URL that comes after the authority but before the -
2436 query string. -
2437 -
2438 \image qurl-ftppath.png -
2439 -
2440 For non-hierarchical schemes, the path will be everything -
2441 following the scheme declaration, as in the following example: -
2442 -
2443 \image qurl-mailtopath.png -
2444 -
2445 \obsolete Use setPath(QString::fromUtf8(path)). -
2446 -
2447 \sa setPath(), encodedPath(), setUserInfo() -
2448*/ -
2449 -
2450/*! -
2451 \fn QByteArray QUrl::encodedPath() const -
2452 \deprecated -
2453 \since 4.4 -
2454 -
2455 Returns the path of the URL if it is defined; otherwise an -
2456 empty string is returned. The returned value will have its -
2457 non-ASCII and other control characters percent-encoded, as in -
2458 toEncoded(). -
2459 -
2460 \obsolete Use path(QUrl::FullyEncoded).toLatin1(). -
2461 -
2462 \sa setEncodedPath(), toEncoded() -
2463*/ -
2464 -
2465/*! -
2466 \since 4.2 -
2467 -
2468 Returns true if this URL contains a Query (i.e., if ? was seen on it). -
2469 -
2470 \sa setQuery(), query(), hasFragment() -
2471*/ -
2472bool QUrl::hasQuery() const -
2473{ -
2474 if (!d) return false;
never executed: return false;
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
2475 return d->hasQuery();
executed: return d->hasQuery();
Execution Count:19
19
2476} -
2477 -
2478/*! -
2479 Sets the query string of the URL to \a query. -
2480 -
2481 This function is useful if you need to pass a query string that -
2482 does not fit into the key-value pattern, or that uses a different -
2483 scheme for encoding special characters than what is suggested by -
2484 QUrl. -
2485 -
2486 Passing a value of QString() to \a query (a null QString) unsets -
2487 the query completely. However, passing a value of QString("") -
2488 will set the query to an empty value, as if the original URL -
2489 had a lone "?". -
2490 -
2491 The \a query data is interpreted according to \a mode: in StrictMode, -
2492 any '%' characters must be followed by exactly two hexadecimal characters -
2493 and some characters (including space) are not allowed in undecoded form. In -
2494 TolerantMode, all characters are accepted in undecoded form and the -
2495 tolerant parser will correct stray '%' not followed by two hex characters. -
2496 In DecodedMode, '%' stand for themselves and encoded characters are not -
2497 possible. -
2498 -
2499 Query strings often contain percent-encoded sequences, so use of -
2500 DecodedMode is discouraged. One special sequence to be aware of is that of -
2501 the plus character ('+'). QUrl does not convert spaces to plus characters, -
2502 even though HTML forms posted by web browsers do. In order to represent an -
2503 actual plus character in a query, the sequence "%2B" is usually used. This -
2504 function will leave "%2B" sequences untouched in TolerantMode or -
2505 StrictMode. -
2506 -
2507 \sa query(), hasQuery() -
2508*/ -
2509void QUrl::setQuery(const QString &query, ParsingMode mode) -
2510{ -
2511 detach();
executed (the execution status of this line is deduced): detach();
-
2512 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2513 -
2514 QString data = query;
executed (the execution status of this line is deduced): QString data = query;
-
2515 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:137
1-137
2516 parseDecodedComponent(data);
executed (the execution status of this line is deduced): parseDecodedComponent(data);
-
2517 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
2518 }
executed: }
Execution Count:1
1
2519 -
2520 d->setQuery(data, 0, data.length());
executed (the execution status of this line is deduced): d->setQuery(data, 0, data.length());
-
2521 if (query.isNull())
evaluated: query.isNull()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:135
3-135
2522 d->sectionIsPresent &= ~QUrlPrivate::Query;
executed: d->sectionIsPresent &= ~QUrlPrivate::Query;
Execution Count:3
3
2523 else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::Query, query))
evaluated: mode == StrictMode
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:133
partially evaluated: !d->validateComponent(QUrlPrivate::Query, query)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-133
2524 d->query.clear();
executed: d->query.clear();
Execution Count:2
2
2525} -
2526 -
2527/*! -
2528 \fn void QUrl::setEncodedQuery(const QByteArray &query) -
2529 \deprecated -
2530 -
2531 Sets the query string of the URL to \a query. The string is -
2532 inserted as-is, and no further encoding is performed when calling -
2533 toEncoded(). -
2534 -
2535 This function is useful if you need to pass a query string that -
2536 does not fit into the key-value pattern, or that uses a different -
2537 scheme for encoding special characters than what is suggested by -
2538 QUrl. -
2539 -
2540 Passing a value of QByteArray() to \a query (a null QByteArray) unsets -
2541 the query completely. However, passing a value of QByteArray("") -
2542 will set the query to an empty value, as if the original URL -
2543 had a lone "?". -
2544 -
2545 \obsolete Use setQuery, which has the same null / empty behavior. -
2546 -
2547 \sa encodedQuery(), hasQuery() -
2548*/ -
2549 -
2550/*! -
2551 \overload -
2552 \since 5.0 -
2553 Sets the query string of the URL to \a query. -
2554 -
2555 This function reconstructs the query string from the QUrlQuery object and -
2556 sets on this QUrl object. This function does not have parsing parameters -
2557 because the QUrlQuery contains data that is already parsed. -
2558 -
2559 \sa query(), hasQuery() -
2560*/ -
2561void QUrl::setQuery(const QUrlQuery &query) -
2562{ -
2563 detach();
never executed (the execution status of this line is deduced): detach();
-
2564 d->clearError();
never executed (the execution status of this line is deduced): d->clearError();
-
2565 -
2566 // we know the data is in the right format -
2567 d->query = query.toString();
never executed (the execution status of this line is deduced): d->query = query.toString();
-
2568 if (query.isEmpty())
never evaluated: query.isEmpty()
0
2569 d->sectionIsPresent &= ~QUrlPrivate::Query;
never executed: d->sectionIsPresent &= ~QUrlPrivate::Query;
0
2570 else -
2571 d->sectionIsPresent |= QUrlPrivate::Query;
never executed: d->sectionIsPresent |= QUrlPrivate::Query;
0
2572} -
2573 -
2574/*! -
2575 \fn void QUrl::setQueryItems(const QList<QPair<QString, QString> > &query) -
2576 \deprecated -
2577 -
2578 Sets the query string of the URL to an encoded version of \a -
2579 query. The contents of \a query are converted to a string -
2580 internally, each pair delimited by the character returned by -
2581 pairDelimiter(), and the key and value are delimited by -
2582 valueDelimiter(). -
2583 -
2584 \note This method does not encode spaces (ASCII 0x20) as plus (+) signs, -
2585 like HTML forms do. If you need that kind of encoding, you must encode -
2586 the value yourself and use QUrl::setEncodedQueryItems. -
2587 -
2588 \obsolete Use QUrlQuery and setQuery(). -
2589 -
2590 \sa queryItems(), setEncodedQueryItems() -
2591*/ -
2592 -
2593/*! -
2594 \fn void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &query) -
2595 \deprecated -
2596 \since 4.4 -
2597 -
2598 Sets the query string of the URL to the encoded version of \a -
2599 query. The contents of \a query are converted to a string -
2600 internally, each pair delimited by the character returned by -
2601 pairDelimiter(), and the key and value are delimited by -
2602 valueDelimiter(). -
2603 -
2604 \obsolete Use QUrlQuery and setQuery(). -
2605 -
2606 \sa encodedQueryItems(), setQueryItems() -
2607*/ -
2608 -
2609/*! -
2610 \fn void QUrl::addQueryItem(const QString &key, const QString &value) -
2611 \deprecated -
2612 -
2613 Inserts the pair \a key = \a value into the query string of the -
2614 URL. -
2615 -
2616 The key/value pair is encoded before it is added to the query. The -
2617 pair is converted into separate strings internally. The \a key and -
2618 \a value is first encoded into UTF-8 and then delimited by the -
2619 character returned by valueDelimiter(). Each key/value pair is -
2620 delimited by the character returned by pairDelimiter(). -
2621 -
2622 \note This method does not encode spaces (ASCII 0x20) as plus (+) signs, -
2623 like HTML forms do. If you need that kind of encoding, you must encode -
2624 the value yourself and use QUrl::addEncodedQueryItem. -
2625 -
2626 \obsolete Use QUrlQuery and setQuery(). -
2627 -
2628 \sa addEncodedQueryItem() -
2629*/ -
2630 -
2631/*! -
2632 \fn void QUrl::addEncodedQueryItem(const QByteArray &key, const QByteArray &value) -
2633 \deprecated -
2634 \since 4.4 -
2635 -
2636 Inserts the pair \a key = \a value into the query string of the -
2637 URL. -
2638 -
2639 \obsolete Use QUrlQuery and setQuery(). -
2640 -
2641 \sa addQueryItem() -
2642*/ -
2643 -
2644/*! -
2645 \fn QList<QPair<QString, QString> > QUrl::queryItems() const -
2646 \deprecated -
2647 -
2648 Returns the query string of the URL, as a map of keys and values. -
2649 -
2650 \note This method does not decode spaces plus (+) signs as spaces (ASCII -
2651 0x20), like HTML forms do. If you need that kind of decoding, you must -
2652 use QUrl::encodedQueryItems and decode the data yourself. -
2653 -
2654 \obsolete Use QUrlQuery. -
2655 -
2656 \sa setQueryItems(), setEncodedQuery() -
2657*/ -
2658 -
2659/*! -
2660 \fn QList<QPair<QByteArray, QByteArray> > QUrl::encodedQueryItems() const -
2661 \deprecated -
2662 \since 4.4 -
2663 -
2664 Returns the query string of the URL, as a map of encoded keys and values. -
2665 -
2666 \obsolete Use QUrlQuery. -
2667 -
2668 \sa setEncodedQueryItems(), setQueryItems(), setEncodedQuery() -
2669*/ -
2670 -
2671/*! -
2672 \fn bool QUrl::hasQueryItem(const QString &key) const -
2673 \deprecated -
2674 -
2675 Returns true if there is a query string pair whose key is equal -
2676 to \a key from the URL. -
2677 -
2678 \obsolete Use QUrlQuery. -
2679 -
2680 \sa hasEncodedQueryItem() -
2681*/ -
2682 -
2683/*! -
2684 \fn bool QUrl::hasEncodedQueryItem(const QByteArray &key) const -
2685 \deprecated -
2686 \since 4.4 -
2687 -
2688 Returns true if there is a query string pair whose key is equal -
2689 to \a key from the URL. -
2690 -
2691 \obsolete Use QUrlQuery. -
2692 -
2693 \sa hasQueryItem() -
2694*/ -
2695 -
2696/*! -
2697 \fn QString QUrl::queryItemValue(const QString &key) const -
2698 \deprecated -
2699 -
2700 Returns the first query string value whose key is equal to \a key -
2701 from the URL. -
2702 -
2703 \note This method does not decode spaces plus (+) signs as spaces (ASCII -
2704 0x20), like HTML forms do. If you need that kind of decoding, you must -
2705 use QUrl::encodedQueryItemValue and decode the data yourself. -
2706 -
2707 \obsolete Use QUrlQuery. -
2708 -
2709 \sa allQueryItemValues() -
2710*/ -
2711 -
2712/*! -
2713 \fn QByteArray QUrl::encodedQueryItemValue(const QByteArray &key) const -
2714 \deprecated -
2715 \since 4.4 -
2716 -
2717 Returns the first query string value whose key is equal to \a key -
2718 from the URL. -
2719 -
2720 \obsolete Use QUrlQuery. -
2721 -
2722 \sa queryItemValue(), allQueryItemValues() -
2723*/ -
2724 -
2725/*! -
2726 \fn QStringList QUrl::allQueryItemValues(const QString &key) const -
2727 \deprecated -
2728 -
2729 Returns the a list of query string values whose key is equal to -
2730 \a key from the URL. -
2731 -
2732 \note This method does not decode spaces plus (+) signs as spaces (ASCII -
2733 0x20), like HTML forms do. If you need that kind of decoding, you must -
2734 use QUrl::allEncodedQueryItemValues and decode the data yourself. -
2735 -
2736 \obsolete Use QUrlQuery. -
2737 -
2738 \sa queryItemValue() -
2739*/ -
2740 -
2741/*! -
2742 \fn QList<QByteArray> QUrl::allEncodedQueryItemValues(const QByteArray &key) const -
2743 \deprecated -
2744 \since 4.4 -
2745 -
2746 Returns the a list of query string values whose key is equal to -
2747 \a key from the URL. -
2748 -
2749 \obsolete Use QUrlQuery. -
2750 -
2751 \sa allQueryItemValues(), queryItemValue(), encodedQueryItemValue() -
2752*/ -
2753 -
2754/*! -
2755 \fn void QUrl::removeQueryItem(const QString &key) -
2756 \deprecated -
2757 -
2758 Removes the first query string pair whose key is equal to \a key -
2759 from the URL. -
2760 -
2761 \obsolete Use QUrlQuery. -
2762 -
2763 \sa removeAllQueryItems() -
2764*/ -
2765 -
2766/*! -
2767 \fn void QUrl::removeEncodedQueryItem(const QByteArray &key) -
2768 \deprecated -
2769 \since 4.4 -
2770 -
2771 Removes the first query string pair whose key is equal to \a key -
2772 from the URL. -
2773 -
2774 \obsolete Use QUrlQuery. -
2775 -
2776 \sa removeQueryItem(), removeAllQueryItems() -
2777*/ -
2778 -
2779/*! -
2780 \fn void QUrl::removeAllQueryItems(const QString &key) -
2781 \deprecated -
2782 -
2783 Removes all the query string pairs whose key is equal to \a key -
2784 from the URL. -
2785 -
2786 \obsolete Use QUrlQuery. -
2787 -
2788 \sa removeQueryItem() -
2789*/ -
2790 -
2791/*! -
2792 \fn void QUrl::removeAllEncodedQueryItems(const QByteArray &key) -
2793 \deprecated -
2794 \since 4.4 -
2795 -
2796 Removes all the query string pairs whose key is equal to \a key -
2797 from the URL. -
2798 -
2799 \obsolete Use QUrlQuery. -
2800 -
2801 \sa removeQueryItem() -
2802*/ -
2803 -
2804/*! -
2805 \fn QByteArray QUrl::encodedQuery() const -
2806 \deprecated -
2807 -
2808 Returns the query string of the URL in percent encoded form. -
2809 -
2810 \obsolete Use query(QUrl::FullyEncoded).toLatin1() -
2811 -
2812 \sa setEncodedQuery(), query() -
2813*/ -
2814 -
2815/*! -
2816 Returns the query string of the URL if there's a query string, or an empty -
2817 result if not. To determine if the parsed URL contained a query string, use -
2818 hasQuery(). -
2819 -
2820 The \a options argument controls how to format the query component. All -
2821 values produce an unambiguous result. With QUrl::FullyDecoded, all -
2822 percent-encoded sequences are decoded; otherwise, the returned value may -
2823 contain some percent-encoded sequences for some control sequences not -
2824 representable in decoded form in QString. -
2825 -
2826 Note that use of QUrl::FullyDecoded in queries is discouraged, as queries -
2827 often contain data that is supposed to remain percent-encoded, including -
2828 the use of the "%2B" sequence to represent a plus character ('+'). -
2829 -
2830 \sa setQuery(), hasQuery() -
2831*/ -
2832QString QUrl::query(ComponentFormattingOptions options) const -
2833{ -
2834 if (!d) return QString();
executed: return QString();
Execution Count:2
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:90
2-90
2835 -
2836 QString result;
executed (the execution status of this line is deduced): QString result;
-
2837 d->appendQuery(result, options, QUrlPrivate::Query);
executed (the execution status of this line is deduced): d->appendQuery(result, options, QUrlPrivate::Query);
-
2838 if (d->hasQuery() && result.isNull())
evaluated: d->hasQuery()
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:22
evaluated: result.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:66
2-68
2839 result.detach();
executed: result.detach();
Execution Count:2
2
2840 return result;
executed: return result;
Execution Count:90
90
2841} -
2842 -
2843/*! -
2844 Sets the fragment of the URL to \a fragment. The fragment is the -
2845 last part of the URL, represented by a '#' followed by a string of -
2846 characters. It is typically used in HTTP for referring to a -
2847 certain link or point on a page: -
2848 -
2849 \image qurl-fragment.png -
2850 -
2851 The fragment is sometimes also referred to as the URL "reference". -
2852 -
2853 Passing an argument of QString() (a null QString) will unset the fragment. -
2854 Passing an argument of QString("") (an empty but not null QString) -
2855 will set the fragment to an empty string (as if the original URL -
2856 had a lone "#"). -
2857 -
2858 The \a fragment data is interpreted according to \a mode: in StrictMode, -
2859 any '%' characters must be followed by exactly two hexadecimal characters -
2860 and some characters (including space) are not allowed in undecoded form. In -
2861 TolerantMode, all characters are accepted in undecoded form and the -
2862 tolerant parser will correct stray '%' not followed by two hex characters. -
2863 In DecodedMode, '%' stand for themselves and encoded characters are not -
2864 possible. -
2865 -
2866 QUrl::DecodedMode should be used when setting the fragment from a data -
2867 source which is not a URL or with a fragment obtained by calling -
2868 fragment() with the QUrl::FullyDecoded formatting option. -
2869 -
2870 \sa fragment(), hasFragment() -
2871*/ -
2872void QUrl::setFragment(const QString &fragment, ParsingMode mode) -
2873{ -
2874 detach();
executed (the execution status of this line is deduced): detach();
-
2875 d->clearError();
executed (the execution status of this line is deduced): d->clearError();
-
2876 -
2877 QString data = fragment;
executed (the execution status of this line is deduced): QString data = fragment;
-
2878 if (mode == DecodedMode) {
evaluated: mode == DecodedMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1339
1-1339
2879 parseDecodedComponent(data);
executed (the execution status of this line is deduced): parseDecodedComponent(data);
-
2880 mode = TolerantMode;
executed (the execution status of this line is deduced): mode = TolerantMode;
-
2881 }
executed: }
Execution Count:1
1
2882 -
2883 d->setFragment(data, 0, data.length());
executed (the execution status of this line is deduced): d->setFragment(data, 0, data.length());
-
2884 if (fragment.isNull())
evaluated: fragment.isNull()
TRUEFALSE
yes
Evaluation Count:691
yes
Evaluation Count:649
649-691
2885 d->sectionIsPresent &= ~QUrlPrivate::Fragment;
executed: d->sectionIsPresent &= ~QUrlPrivate::Fragment;
Execution Count:691
691
2886 else if (mode == StrictMode && !d->validateComponent(QUrlPrivate::Fragment, fragment))
evaluated: mode == StrictMode
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:647
partially evaluated: !d->validateComponent(QUrlPrivate::Fragment, fragment)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-647
2887 d->fragment.clear();
executed: d->fragment.clear();
Execution Count:2
2
2888} -
2889 -
2890/*! -
2891 Returns the fragment of the URL. To determine if the parsed URL contained a -
2892 fragment, use hasFragment(). -
2893 -
2894 The \a options argument controls how to format the fragment component. All -
2895 values produce an unambiguous result. With QUrl::FullyDecoded, all -
2896 percent-encoded sequences are decoded; otherwise, the returned value may -
2897 contain some percent-encoded sequences for some control sequences not -
2898 representable in decoded form in QString. -
2899 -
2900 Note that QUrl::FullyDecoded may cause data loss if those non-representable -
2901 sequences are present. It is recommended to use that value when the result -
2902 will be used in a non-URL context. -
2903 -
2904 \sa setFragment(), hasFragment() -
2905*/ -
2906QString QUrl::fragment(ComponentFormattingOptions options) const -
2907{ -
2908 if (!d) return QString();
executed: return QString();
Execution Count:2
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:131
2-131
2909 -
2910 QString result;
executed (the execution status of this line is deduced): QString result;
-
2911 d->appendFragment(result, options);
executed (the execution status of this line is deduced): d->appendFragment(result, options);
-
2912 if (d->hasFragment() && result.isNull())
evaluated: d->hasFragment()
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:67
evaluated: result.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:62
2-67
2913 result.detach();
executed: result.detach();
Execution Count:2
2
2914 return result;
executed: return result;
Execution Count:131
131
2915} -
2916 -
2917/*! -
2918 \fn void QUrl::setEncodedFragment(const QByteArray &fragment) -
2919 \deprecated -
2920 \since 4.4 -
2921 -
2922 Sets the URL's fragment to the percent-encoded \a fragment. The fragment is the -
2923 last part of the URL, represented by a '#' followed by a string of -
2924 characters. It is typically used in HTTP for referring to a -
2925 certain link or point on a page: -
2926 -
2927 \image qurl-fragment.png -
2928 -
2929 The fragment is sometimes also referred to as the URL "reference". -
2930 -
2931 Passing an argument of QByteArray() (a null QByteArray) will unset -
2932 the fragment. Passing an argument of QByteArray("") (an empty but -
2933 not null QByteArray) will set the fragment to an empty string (as -
2934 if the original URL had a lone "#"). -
2935 -
2936 \obsolete Use setFragment(), which has the same behavior of null / empty. -
2937 -
2938 \sa setFragment(), encodedFragment() -
2939*/ -
2940 -
2941/*! -
2942 \fn QByteArray QUrl::encodedFragment() const -
2943 \deprecated -
2944 \since 4.4 -
2945 -
2946 Returns the fragment of the URL if it is defined; otherwise an -
2947 empty string is returned. The returned value will have its -
2948 non-ASCII and other control characters percent-encoded, as in -
2949 toEncoded(). -
2950 -
2951 \obsolete Use query(QUrl::FullyEncoded).toLatin1(). -
2952 -
2953 \sa setEncodedFragment(), toEncoded() -
2954*/ -
2955 -
2956/*! -
2957 \since 4.2 -
2958 -
2959 Returns true if this URL contains a fragment (i.e., if # was seen on it). -
2960 -
2961 \sa fragment(), setFragment() -
2962*/ -
2963bool QUrl::hasFragment() const -
2964{ -
2965 if (!d) return false;
never executed: return false;
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:62
0-62
2966 return d->hasFragment();
executed: return d->hasFragment();
Execution Count:62
62
2967} -
2968 -
2969/*! -
2970 \since 4.8 -
2971 -
2972 Returns the TLD (Top-Level Domain) of the URL, (e.g. .co.uk, .net). -
2973 Note that the return value is prefixed with a '.' unless the -
2974 URL does not contain a valid TLD, in which case the function returns -
2975 an empty string. -
2976 -
2977 If \a options includes EncodeUnicode, the returned string will be in -
2978 ASCII Compatible Encoding. -
2979*/ -
2980QString QUrl::topLevelDomain(ComponentFormattingOptions options) const -
2981{ -
2982 QString tld = qTopLevelDomain(host());
executed (the execution status of this line is deduced): QString tld = qTopLevelDomain(host());
-
2983 if (options & EncodeUnicode) {
partially evaluated: options & EncodeUnicode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
2984 return qt_ACE_do(tld, ToAceOnly);
never executed: return qt_ACE_do(tld, ToAceOnly);
0
2985 } -
2986 return tld;
executed: return tld;
Execution Count:9
9
2987} -
2988 -
2989/*! -
2990 Returns the result of the merge of this URL with \a relative. This -
2991 URL is used as a base to convert \a relative to an absolute URL. -
2992 -
2993 If \a relative is not a relative URL, this function will return \a -
2994 relative directly. Otherwise, the paths of the two URLs are -
2995 merged, and the new URL returned has the scheme and authority of -
2996 the base URL, but with the merged path, as in the following -
2997 example: -
2998 -
2999 \snippet code/src_corelib_io_qurl.cpp 5 -
3000 -
3001 Calling resolved() with ".." returns a QUrl whose directory is -
3002 one level higher than the original. Similarly, calling resolved() -
3003 with "../.." removes two levels from the path. If \a relative is -
3004 "/", the path becomes "/". -
3005 -
3006 \sa isRelative() -
3007*/ -
3008QUrl QUrl::resolved(const QUrl &relative) const -
3009{ -
3010 if (!d) return relative;
executed: return relative;
Execution Count:24
evaluated: !d
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:4452
24-4452
3011 if (!relative.d) return *this;
never executed: return *this;
partially evaluated: !relative.d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4458
0-4458
3012 -
3013 QUrl t;
executed (the execution status of this line is deduced): QUrl t;
-
3014 // be non strict and allow scheme in relative url -
3015 if (!relative.d->scheme.isEmpty() && relative.d->scheme != d->scheme) {
evaluated: !relative.d->scheme.isEmpty()
TRUEFALSE
yes
Evaluation Count:1071
yes
Evaluation Count:3385
evaluated: relative.d->scheme != d->scheme
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1068
6-3385
3016 t = relative;
executed (the execution status of this line is deduced): t = relative;
-
3017 t.detach();
executed (the execution status of this line is deduced): t.detach();
-
3018 } else {
executed: }
Execution Count:6
6
3019 if (relative.d->hasAuthority()) {
evaluated: relative.d->hasAuthority()
TRUEFALSE
yes
Evaluation Count:1039
yes
Evaluation Count:3414
1039-3414
3020 t = relative;
executed (the execution status of this line is deduced): t = relative;
-
3021 t.detach();
executed (the execution status of this line is deduced): t.detach();
-
3022 } else {
executed: }
Execution Count:1046
1046
3023 t.d = new QUrlPrivate;
executed (the execution status of this line is deduced): t.d = new QUrlPrivate;
-
3024 -
3025 // copy the authority -
3026 t.d->userName = d->userName;
executed (the execution status of this line is deduced): t.d->userName = d->userName;
-
3027 t.d->password = d->password;
executed (the execution status of this line is deduced): t.d->password = d->password;
-
3028 t.d->host = d->host;
executed (the execution status of this line is deduced): t.d->host = d->host;
-
3029 t.d->port = d->port;
executed (the execution status of this line is deduced): t.d->port = d->port;
-
3030 t.d->sectionIsPresent = d->sectionIsPresent & QUrlPrivate::Authority;
executed (the execution status of this line is deduced): t.d->sectionIsPresent = d->sectionIsPresent & QUrlPrivate::Authority;
-
3031 -
3032 if (relative.d->path.isEmpty()) {
evaluated: relative.d->path.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3407
5-3407
3033 t.d->path = d->path;
executed (the execution status of this line is deduced): t.d->path = d->path;
-
3034 if (relative.d->hasQuery()) {
evaluated: relative.d->hasQuery()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
3035 t.d->query = relative.d->query;
executed (the execution status of this line is deduced): t.d->query = relative.d->query;
-
3036 t.d->sectionIsPresent |= QUrlPrivate::Query;
executed (the execution status of this line is deduced): t.d->sectionIsPresent |= QUrlPrivate::Query;
-
3037 } else if (d->hasQuery()) {
executed: }
Execution Count:1
evaluated: d->hasQuery()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
1-2
3038 t.d->query = d->query;
executed (the execution status of this line is deduced): t.d->query = d->query;
-
3039 t.d->sectionIsPresent |= QUrlPrivate::Query;
executed (the execution status of this line is deduced): t.d->sectionIsPresent |= QUrlPrivate::Query;
-
3040 }
executed: }
Execution Count:2
2
3041 } else { -
3042 t.d->path = relative.d->path.startsWith(QLatin1Char('/'))
evaluated: relative.d->path.startsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:3371
36-3371
3043 ? relative.d->path
executed (the execution status of this line is deduced): ? relative.d->path
-
3044 : d->mergePaths(relative.d->path);
executed (the execution status of this line is deduced): : d->mergePaths(relative.d->path);
-
3045 if (relative.d->hasQuery()) {
evaluated: relative.d->hasQuery()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:3385
24-3385
3046 t.d->query = relative.d->query;
executed (the execution status of this line is deduced): t.d->query = relative.d->query;
-
3047 t.d->sectionIsPresent |= QUrlPrivate::Query;
executed (the execution status of this line is deduced): t.d->sectionIsPresent |= QUrlPrivate::Query;
-
3048 }
executed: }
Execution Count:24
24
3049 }
executed: }
Execution Count:3406
3406
3050 } -
3051 t.d->scheme = d->scheme;
executed (the execution status of this line is deduced): t.d->scheme = d->scheme;
-
3052 if (d->hasScheme())
evaluated: d->hasScheme()
TRUEFALSE
yes
Evaluation Count:4453
yes
Evaluation Count:11
11-4453
3053 t.d->sectionIsPresent |= QUrlPrivate::Scheme;
executed: t.d->sectionIsPresent |= QUrlPrivate::Scheme;
Execution Count:4452
4452
3054 else -
3055 t.d->sectionIsPresent &= ~QUrlPrivate::Scheme;
executed: t.d->sectionIsPresent &= ~QUrlPrivate::Scheme;
Execution Count:11
11
3056 } -
3057 t.d->fragment = relative.d->fragment;
executed (the execution status of this line is deduced): t.d->fragment = relative.d->fragment;
-
3058 if (relative.d->hasFragment())
evaluated: relative.d->hasFragment()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:4458
10-4458
3059 t.d->sectionIsPresent |= QUrlPrivate::Fragment;
executed: t.d->sectionIsPresent |= QUrlPrivate::Fragment;
Execution Count:10
10
3060 else -
3061 t.d->sectionIsPresent &= ~QUrlPrivate::Fragment;
executed: t.d->sectionIsPresent &= ~QUrlPrivate::Fragment;
Execution Count:4454
4454
3062 -
3063 removeDotsFromPath(&t.d->path);
executed (the execution status of this line is deduced): removeDotsFromPath(&t.d->path);
-
3064 -
3065#if defined(QURL_DEBUG) -
3066 qDebug("QUrl(\"%s\").resolved(\"%s\") = \"%s\"", -
3067 qPrintable(url()), -
3068 qPrintable(relative.url()), -
3069 qPrintable(t.url())); -
3070#endif -
3071 return t;
executed: return t;
Execution Count:4455
4455
3072} -
3073 -
3074/*! -
3075 Returns true if the URL is relative; otherwise returns false. A URL is -
3076 relative reference if its scheme is undefined; this function is therefore -
3077 equivalent to calling scheme().isEmpty(). -
3078 -
3079 Relative references are defined in RFC 3986 section 4.2. -
3080*/ -
3081bool QUrl::isRelative() const -
3082{ -
3083 if (!d) return true;
executed: return true;
Execution Count:3
evaluated: !d
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:230
3-230
3084 return !d->hasScheme();
executed: return !d->hasScheme();
Execution Count:230
230
3085} -
3086 -
3087/*! -
3088 Returns a string representation of the URL. The output can be customized by -
3089 passing flags with \a options. The option QUrl::FullyDecoded is not -
3090 permitted in this function since it would generate ambiguous data. -
3091 -
3092 The resulting QString can be passed back to a QUrl later on. -
3093 -
3094 Synonym for toString(options). -
3095 -
3096 \sa FormattingOptions, toEncoded(), toString() -
3097*/ -
3098QString QUrl::url(FormattingOptions options) const -
3099{ -
3100 return toString(options);
executed: return toString(options);
Execution Count:43
43
3101} -
3102 -
3103/*! -
3104 Returns a string representation of the URL. The output can be customized by -
3105 passing flags with \a options. The option QUrl::FullyDecoded is not -
3106 permitted in this function since it would generate ambiguous data. -
3107 -
3108 The default formatting option is \l{QUrl::FormattingOptions}{PrettyDecoded}. -
3109 -
3110 \sa FormattingOptions, url(), setUrl() -
3111*/ -
3112QString QUrl::toString(FormattingOptions options) const -
3113{ -
3114 if (!isValid()) {
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:6162
94-6162
3115 // also catches isEmpty() -
3116 return QString();
executed: return QString();
Execution Count:94
94
3117 } -
3118 if (options == QUrl::FullyDecoded) {
partially evaluated: options == QUrl::FullyDecoded
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6162
0-6162
3119 qWarning("QUrl: QUrl::FullyDecoded is not permitted when reconstructing the full URL");
never executed (the execution status of this line is deduced): QMessageLogger("io/qurl.cpp", 3119, __PRETTY_FUNCTION__).warning("QUrl: QUrl::FullyDecoded is not permitted when reconstructing the full URL");
-
3120 options = QUrl::PrettyDecoded;
never executed (the execution status of this line is deduced): options = QUrl::PrettyDecoded;
-
3121 }
never executed: }
0
3122 -
3123 // return just the path if: -
3124 // - QUrl::PreferLocalFile is passed -
3125 // - QUrl::RemovePath isn't passed (rather stupid if the user did...) -
3126 // - there's no query or fragment to return -
3127 // that is, either they aren't present, or we're removing them -
3128 // - it's a local file -
3129 // (test done last since it's the most expensive) -
3130 if (options.testFlag(QUrl::PreferLocalFile) && !options.testFlag(QUrl::RemovePath)
evaluated: options.testFlag(QUrl::PreferLocalFile)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6156
partially evaluated: !options.testFlag(QUrl::RemovePath)
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6156
3131 && (!d->hasQuery() || options.testFlag(QUrl::RemoveQuery))
partially evaluated: !d->hasQuery()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
never evaluated: options.testFlag(QUrl::RemoveQuery)
0-6
3132 && (!d->hasFragment() || options.testFlag(QUrl::RemoveFragment))
evaluated: !d->hasFragment()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
partially evaluated: options.testFlag(QUrl::RemoveFragment)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-5
3133 && isLocalFile()) {
evaluated: isLocalFile()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
3134 return path(options);
executed: return path(options);
Execution Count:3
3
3135 } -
3136 -
3137 QString url;
executed (the execution status of this line is deduced): QString url;
-
3138 -
3139 // for the full URL, we consider that the reserved characters are prettier if encoded -
3140 if (options & DecodeReserved)
evaluated: options & DecodeReserved
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:6134
25-6134
3141 options &= ~EncodeReserved;
executed: options &= ~EncodeReserved;
Execution Count:25
25
3142 else -
3143 options |= EncodeReserved;
executed: options |= EncodeReserved;
Execution Count:6134
6134
3144 -
3145 if (!(options & QUrl::RemoveScheme) && d->hasScheme())
evaluated: !(options & QUrl::RemoveScheme)
TRUEFALSE
yes
Evaluation Count:5154
yes
Evaluation Count:1006
evaluated: d->hasScheme()
TRUEFALSE
yes
Evaluation Count:4962
yes
Evaluation Count:194
194-5154
3146 url += d->scheme + QLatin1Char(':');
executed: url += d->scheme + QLatin1Char(':');
Execution Count:4961
4961
3147 -
3148 bool pathIsAbsolute = d->path.startsWith(QLatin1Char('/'));
executed (the execution status of this line is deduced): bool pathIsAbsolute = d->path.startsWith(QLatin1Char('/'));
-
3149 if (!((options & QUrl::RemoveAuthority) == QUrl::RemoveAuthority) && d->hasAuthority()) {
evaluated: !((options & QUrl::RemoveAuthority) == QUrl::RemoveAuthority)
TRUEFALSE
yes
Evaluation Count:5184
yes
Evaluation Count:977
evaluated: d->hasAuthority()
TRUEFALSE
yes
Evaluation Count:4322
yes
Evaluation Count:860
860-5184
3150 url += QLatin1String("//");
executed (the execution status of this line is deduced): url += QLatin1String("//");
-
3151 d->appendAuthority(url, options, QUrlPrivate::FullUrl);
executed (the execution status of this line is deduced): d->appendAuthority(url, options, QUrlPrivate::FullUrl);
-
3152 } else if (isLocalFile() && pathIsAbsolute) {
executed: }
Execution Count:4320
evaluated: isLocalFile()
TRUEFALSE
yes
Evaluation Count:593
yes
Evaluation Count:1244
evaluated: pathIsAbsolute
TRUEFALSE
yes
Evaluation Count:360
yes
Evaluation Count:233
233-4320
3153 url += QLatin1String("//");
executed (the execution status of this line is deduced): url += QLatin1String("//");
-
3154 }
executed: }
Execution Count:360
360
3155 -
3156 if (!(options & QUrl::RemovePath)) {
evaluated: !(options & QUrl::RemovePath)
TRUEFALSE
yes
Evaluation Count:4778
yes
Evaluation Count:1378
1378-4778
3157 d->appendPath(url, options, QUrlPrivate::FullUrl);
executed (the execution status of this line is deduced): d->appendPath(url, options, QUrlPrivate::FullUrl);
-
3158 // check if we need to remove trailing slashes -
3159 if ((options & StripTrailingSlash) && !d->path.isEmpty() && d->path != QLatin1String("/") && url.endsWith(QLatin1Char('/')))
evaluated: (options & StripTrailingSlash)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:4770
evaluated: !d->path.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
evaluated: d->path != QLatin1String("/")
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
evaluated: url.endsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4770
3160 url.chop(1);
executed: url.chop(1);
Execution Count:4
4
3161 }
executed: }
Execution Count:4776
4776
3162 -
3163 if (!(options & QUrl::RemoveQuery) && d->hasQuery()) {
evaluated: !(options & QUrl::RemoveQuery)
TRUEFALSE
yes
Evaluation Count:4772
yes
Evaluation Count:1386
evaluated: d->hasQuery()
TRUEFALSE
yes
Evaluation Count:391
yes
Evaluation Count:4380
391-4772
3164 url += QLatin1Char('?');
executed (the execution status of this line is deduced): url += QLatin1Char('?');
-
3165 d->appendQuery(url, options, QUrlPrivate::FullUrl);
executed (the execution status of this line is deduced): d->appendQuery(url, options, QUrlPrivate::FullUrl);
-
3166 }
executed: }
Execution Count:391
391
3167 if (!(options & QUrl::RemoveFragment) && d->hasFragment()) {
evaluated: !(options & QUrl::RemoveFragment)
TRUEFALSE
yes
Evaluation Count:4334
yes
Evaluation Count:1823
evaluated: d->hasFragment()
TRUEFALSE
yes
Evaluation Count:764
yes
Evaluation Count:3570
764-4334
3168 url += QLatin1Char('#');
executed (the execution status of this line is deduced): url += QLatin1Char('#');
-
3169 d->appendFragment(url, options);
executed (the execution status of this line is deduced): d->appendFragment(url, options);
-
3170 }
executed: }
Execution Count:764
764
3171 -
3172 return url;
executed: return url;
Execution Count:6157
6157
3173} -
3174 -
3175/*! -
3176 \since 5.0 -
3177 -
3178 Returns a human-displayable string representation of the URL. -
3179 The output can be customized by passing flags with \a options. -
3180 The option RemovePassword is always enabled, since passwords -
3181 should never be shown back to users. -
3182 -
3183 With the default options, the resulting QString can be passed back -
3184 to a QUrl later on, but any password that was present initially will -
3185 be lost. -
3186 -
3187 \sa FormattingOptions, toEncoded(), toString() -
3188*/ -
3189 -
3190QString QUrl::toDisplayString(FormattingOptions options) const -
3191{ -
3192 return toString(options | RemovePassword);
executed: return toString(options | RemovePassword);
Execution Count:11
11
3193} -
3194 -
3195/*! -
3196 Returns the encoded representation of the URL if it's valid; -
3197 otherwise an empty QByteArray is returned. The output can be -
3198 customized by passing flags with \a options. -
3199 -
3200 The user info, path and fragment are all converted to UTF-8, and -
3201 all non-ASCII characters are then percent encoded. The host name -
3202 is encoded using Punycode. -
3203*/ -
3204QByteArray QUrl::toEncoded(FormattingOptions options) const -
3205{ -
3206 options &= ~(FullyDecoded | FullyEncoded);
executed (the execution status of this line is deduced): options &= ~(FullyDecoded | FullyEncoded);
-
3207 QString stringForm = toString(options | FullyEncoded);
executed (the execution status of this line is deduced): QString stringForm = toString(options | FullyEncoded);
-
3208 return stringForm.toLatin1();
executed: return stringForm.toLatin1();
Execution Count:3802
3802
3209} -
3210 -
3211/*! -
3212 \fn QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode parsingMode) -
3213 -
3214 Parses \a input and returns the corresponding QUrl. \a input is -
3215 assumed to be in encoded form, containing only ASCII characters. -
3216 -
3217 Parses the URL using \a parsingMode. See setUrl() for more information on -
3218 this parameter. QUrl::DecodedMode is not permitted in this context. -
3219 -
3220 \sa toEncoded(), setUrl() -
3221*/ -
3222QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode mode) -
3223{ -
3224 return QUrl(QString::fromUtf8(input.constData(), input.size()), mode);
executed: return QUrl(QString::fromUtf8(input.constData(), input.size()), mode);
Execution Count:245
245
3225} -
3226 -
3227/*! -
3228 Returns a decoded copy of \a input. \a input is first decoded from -
3229 percent encoding, then converted from UTF-8 to unicode. -
3230*/ -
3231QString QUrl::fromPercentEncoding(const QByteArray &input) -
3232{ -
3233 QByteArray ba = QByteArray::fromPercentEncoding(input);
executed (the execution status of this line is deduced): QByteArray ba = QByteArray::fromPercentEncoding(input);
-
3234 return QString::fromUtf8(ba, ba.size());
executed: return QString::fromUtf8(ba, ba.size());
Execution Count:14
14
3235} -
3236 -
3237/*! -
3238 Returns an encoded copy of \a input. \a input is first converted -
3239 to UTF-8, and all ASCII-characters that are not in the unreserved group -
3240 are percent encoded. To prevent characters from being percent encoded -
3241 pass them to \a exclude. To force characters to be percent encoded pass -
3242 them to \a include. -
3243 -
3244 Unreserved is defined as: -
3245 ALPHA / DIGIT / "-" / "." / "_" / "~" -
3246 -
3247 \snippet code/src_corelib_io_qurl.cpp 6 -
3248*/ -
3249QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclude, const QByteArray &include) -
3250{ -
3251 return input.toUtf8().toPercentEncoding(exclude, include);
executed: return input.toUtf8().toPercentEncoding(exclude, include);
Execution Count:13
13
3252} -
3253 -
3254/*! -
3255 \internal -
3256 \since 5.0 -
3257 Used in the setEncodedXXX compatibility functions. Converts \a ba to -
3258 QString form. -
3259*/ -
3260QString QUrl::fromEncodedComponent_helper(const QByteArray &ba) -
3261{ -
3262 return qt_urlRecodeByteArray(ba);
executed: return qt_urlRecodeByteArray(ba);
Execution Count:37
37
3263} -
3264 -
3265/*! -
3266 \fn QByteArray QUrl::toPunycode(const QString &uc) -
3267 \obsolete -
3268 Returns a \a uc in Punycode encoding. -
3269 -
3270 Punycode is a Unicode encoding used for internationalized domain -
3271 names, as defined in RFC3492. If you want to convert a domain name from -
3272 Unicode to its ASCII-compatible representation, use toAce(). -
3273*/ -
3274 -
3275/*! -
3276 \fn QString QUrl::fromPunycode(const QByteArray &pc) -
3277 \obsolete -
3278 Returns the Punycode decoded representation of \a pc. -
3279 -
3280 Punycode is a Unicode encoding used for internationalized domain -
3281 names, as defined in RFC3492. If you want to convert a domain from -
3282 its ASCII-compatible encoding to the Unicode representation, use -
3283 fromAce(). -
3284*/ -
3285 -
3286/*! -
3287 \since 4.2 -
3288 -
3289 Returns the Unicode form of the given domain name -
3290 \a domain, which is encoded in the ASCII Compatible Encoding (ACE). -
3291 The result of this function is considered equivalent to \a domain. -
3292 -
3293 If the value in \a domain cannot be encoded, it will be converted -
3294 to QString and returned. -
3295 -
3296 The ASCII Compatible Encoding (ACE) is defined by RFC 3490, RFC 3491 -
3297 and RFC 3492. It is part of the Internationalizing Domain Names in -
3298 Applications (IDNA) specification, which allows for domain names -
3299 (like \c "example.com") to be written using international -
3300 characters. -
3301*/ -
3302QString QUrl::fromAce(const QByteArray &domain) -
3303{ -
3304 return qt_ACE_do(QString::fromLatin1(domain), NormalizeAce);
executed: return qt_ACE_do(QString::fromLatin1(domain), NormalizeAce);
Execution Count:153
153
3305} -
3306 -
3307/*! -
3308 \since 4.2 -
3309 -
3310 Returns the ASCII Compatible Encoding of the given domain name \a domain. -
3311 The result of this function is considered equivalent to \a domain. -
3312 -
3313 The ASCII-Compatible Encoding (ACE) is defined by RFC 3490, RFC 3491 -
3314 and RFC 3492. It is part of the Internationalizing Domain Names in -
3315 Applications (IDNA) specification, which allows for domain names -
3316 (like \c "example.com") to be written using international -
3317 characters. -
3318 -
3319 This function return an empty QByteArra if \a domain is not a valid -
3320 hostname. Note, in particular, that IPv6 literals are not valid domain -
3321 names. -
3322*/ -
3323QByteArray QUrl::toAce(const QString &domain) -
3324{ -
3325 QString result = qt_ACE_do(domain, ToAceOnly);
executed (the execution status of this line is deduced): QString result = qt_ACE_do(domain, ToAceOnly);
-
3326 return result.toLatin1();
executed: return result.toLatin1();
Execution Count:1233
1233
3327} -
3328 -
3329/*! -
3330 \internal -
3331 -
3332 Returns true if this URL is "less than" the given \a url. This -
3333 provides a means of ordering URLs. -
3334*/ -
3335bool QUrl::operator <(const QUrl &url) const -
3336{ -
3337 if (!d || !url.d) {
evaluated: !d
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:139
evaluated: !url.d
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:131
8-139
3338 bool thisIsEmpty = !d || d->isEmpty();
evaluated: !d
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:8
evaluated: d->isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5
3-18
3339 bool thatIsEmpty = !url.d || url.d->isEmpty();
evaluated: !url.d
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:9
evaluated: url.d->isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-17
3340 -
3341 // sort an empty URL first -
3342 return thisIsEmpty && !thatIsEmpty;
executed: return thisIsEmpty && !thatIsEmpty;
Execution Count:26
26
3343 } -
3344 -
3345 int cmp;
executed (the execution status of this line is deduced): int cmp;
-
3346 cmp = d->scheme.compare(url.d->scheme);
executed (the execution status of this line is deduced): cmp = d->scheme.compare(url.d->scheme);
-
3347 if (cmp != 0)
evaluated: cmp != 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:114
17-114
3348 return cmp < 0;
executed: return cmp < 0;
Execution Count:17
17
3349 -
3350 cmp = d->userName.compare(url.d->userName);
executed (the execution status of this line is deduced): cmp = d->userName.compare(url.d->userName);
-
3351 if (cmp != 0)
partially evaluated: cmp != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:114
0-114
3352 return cmp < 0;
never executed: return cmp < 0;
0
3353 -
3354 cmp = d->password.compare(url.d->password);
executed (the execution status of this line is deduced): cmp = d->password.compare(url.d->password);
-
3355 if (cmp != 0)
partially evaluated: cmp != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:114
0-114
3356 return cmp < 0;
never executed: return cmp < 0;
0
3357 -
3358 cmp = d->host.compare(url.d->host);
executed (the execution status of this line is deduced): cmp = d->host.compare(url.d->host);
-
3359 if (cmp != 0)
partially evaluated: cmp != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:114
0-114
3360 return cmp < 0;
never executed: return cmp < 0;
0
3361 -
3362 if (d->port != url.d->port)
evaluated: d->port != url.d->port
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:106
8-106
3363 return d->port < url.d->port;
executed: return d->port < url.d->port;
Execution Count:8
8
3364 -
3365 cmp = d->path.compare(url.d->path);
executed (the execution status of this line is deduced): cmp = d->path.compare(url.d->path);
-
3366 if (cmp != 0)
evaluated: cmp != 0
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:85
21-85
3367 return cmp < 0;
executed: return cmp < 0;
Execution Count:21
21
3368 -
3369 if (d->hasQuery() != url.d->hasQuery())
evaluated: d->hasQuery() != url.d->hasQuery()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:77
8-77
3370 return url.d->hasQuery();
executed: return url.d->hasQuery();
Execution Count:8
8
3371 -
3372 cmp = d->query.compare(url.d->query);
executed (the execution status of this line is deduced): cmp = d->query.compare(url.d->query);
-
3373 if (cmp != 0)
evaluated: cmp != 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:76
1-76
3374 return cmp < 0;
executed: return cmp < 0;
Execution Count:1
1
3375 -
3376 if (d->hasFragment() != url.d->hasFragment())
evaluated: d->hasFragment() != url.d->hasFragment()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:68
8-68
3377 return url.d->hasFragment();
executed: return url.d->hasFragment();
Execution Count:8
8
3378 -
3379 cmp = d->fragment.compare(url.d->fragment);
executed (the execution status of this line is deduced): cmp = d->fragment.compare(url.d->fragment);
-
3380 return cmp < 0;
executed: return cmp < 0;
Execution Count:68
68
3381} -
3382 -
3383/*! -
3384 Returns true if this URL and the given \a url are equal; -
3385 otherwise returns false. -
3386*/ -
3387bool QUrl::operator ==(const QUrl &url) const -
3388{ -
3389 if (!d && !url.d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:213
yes
Evaluation Count:2221
evaluated: !url.d
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:113
100-2221
3390 return true;
executed: return true;
Execution Count:100
100
3391 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:2221
113-2221
3392 return url.d->isEmpty();
executed: return url.d->isEmpty();
Execution Count:113
113
3393 if (!url.d)
evaluated: !url.d
TRUEFALSE
yes
Evaluation Count:328
yes
Evaluation Count:1893
328-1893
3394 return d->isEmpty();
executed: return d->isEmpty();
Execution Count:328
328
3395 -
3396 // Compare which sections are present, but ignore Host -
3397 // which is set by parsing but not by construction, when empty. -
3398 const int mask = QUrlPrivate::FullUrl & ~QUrlPrivate::Host;
executed (the execution status of this line is deduced): const int mask = QUrlPrivate::FullUrl & ~QUrlPrivate::Host;
-
3399 return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3400 d->scheme == url.d->scheme &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3401 d->userName == url.d->userName &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3402 d->password == url.d->password &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3403 d->host == url.d->host &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3404 d->port == url.d->port &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3405 d->path == url.d->path &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3406 d->query == url.d->query &&
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3407 d->fragment == url.d->fragment;
executed: return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && d->password == url.d->password && d->host == url.d->host && d->port == url.d->port && d->path == url.d->path && d->query == url.d->query && d->fragment == url.d->fragment;
Execution Count:1893
1893
3408} -
3409 -
3410/*! -
3411 Returns true if this URL and the given \a url are not equal; -
3412 otherwise returns false. -
3413*/ -
3414bool QUrl::operator !=(const QUrl &url) const -
3415{ -
3416 return !(*this == url);
executed: return !(*this == url);
Execution Count:100
100
3417} -
3418 -
3419/*! -
3420 Assigns the specified \a url to this object. -
3421*/ -
3422QUrl &QUrl::operator =(const QUrl &url) -
3423{ -
3424 if (!d) {
evaluated: !d
TRUEFALSE
yes
Evaluation Count:5742
yes
Evaluation Count:332
332-5742
3425 if (url.d) {
evaluated: url.d
TRUEFALSE
yes
Evaluation Count:4779
yes
Evaluation Count:960
960-4779
3426 url.d->ref.ref();
executed (the execution status of this line is deduced): url.d->ref.ref();
-
3427 d = url.d;
executed (the execution status of this line is deduced): d = url.d;
-
3428 }
executed: }
Execution Count:4805
4805
3429 } else {
executed: }
Execution Count:5766
5766
3430 if (url.d)
partially evaluated: url.d
TRUEFALSE
yes
Evaluation Count:332
no
Evaluation Count:0
0-332
3431 qAtomicAssign(d, url.d);
executed: qAtomicAssign(d, url.d);
Execution Count:332
332
3432 else -
3433 clear();
never executed: clear();
0
3434 } -
3435 return *this;
executed: return *this;
Execution Count:6098
6098
3436} -
3437 -
3438/*! -
3439 Assigns the specified \a url to this object. -
3440*/ -
3441QUrl &QUrl::operator =(const QString &url) -
3442{ -
3443 if (url.isEmpty()) {
partially evaluated: url.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
3444 clear();
never executed (the execution status of this line is deduced): clear();
-
3445 } else {
never executed: }
0
3446 detach();
executed (the execution status of this line is deduced): detach();
-
3447 d->parse(url, TolerantMode);
executed (the execution status of this line is deduced): d->parse(url, TolerantMode);
-
3448 }
executed: }
Execution Count:10
10
3449 return *this;
executed: return *this;
Execution Count:10
10
3450} -
3451 -
3452/*! -
3453 \fn void QUrl::swap(QUrl &other) -
3454 \since 4.8 -
3455 -
3456 Swaps URL \a other with this URL. This operation is very -
3457 fast and never fails. -
3458*/ -
3459 -
3460/*! -
3461 \internal -
3462 -
3463 Forces a detach. -
3464*/ -
3465void QUrl::detach() -
3466{ -
3467 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:11257
yes
Evaluation Count:15639
11257-15639
3468 d = new QUrlPrivate;
executed: d = new QUrlPrivate;
Execution Count:11257
11257
3469 else -
3470 qAtomicDetach(d);
executed: qAtomicDetach(d);
Execution Count:15637
15637
3471} -
3472 -
3473/*! -
3474 \internal -
3475*/ -
3476bool QUrl::isDetached() const -
3477{ -
3478 return !d || d->ref.load() == 1;
never executed: return !d || d->ref.load() == 1;
0
3479} -
3480 -
3481 -
3482/*! -
3483 Returns a QUrl representation of \a localFile, interpreted as a local -
3484 file. This function accepts paths separated by slashes as well as the -
3485 native separator for this platform. -
3486 -
3487 This function also accepts paths with a doubled leading slash (or -
3488 backslash) to indicate a remote file, as in -
3489 "//servername/path/to/file.txt". Note that only certain platforms can -
3490 actually open this file using QFile::open(). -
3491 -
3492 \sa toLocalFile(), isLocalFile(), QDir::toNativeSeparators() -
3493*/ -
3494QUrl QUrl::fromLocalFile(const QString &localFile) -
3495{ -
3496 QUrl url;
executed (the execution status of this line is deduced): QUrl url;
-
3497 url.setScheme(fileScheme());
executed (the execution status of this line is deduced): url.setScheme(fileScheme());
-
3498 QString deslashified = QDir::fromNativeSeparators(localFile);
executed (the execution status of this line is deduced): QString deslashified = QDir::fromNativeSeparators(localFile);
-
3499 -
3500 // magic for drives on windows -
3501 if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) {
evaluated: deslashified.length() > 1
TRUEFALSE
yes
Evaluation Count:1513
yes
Evaluation Count:526
evaluated: deslashified.at(1) == QLatin1Char(':')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1512
partially evaluated: deslashified.at(0) != QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1513
3502 deslashified.prepend(QLatin1Char('/'));
executed (the execution status of this line is deduced): deslashified.prepend(QLatin1Char('/'));
-
3503 } else if (deslashified.startsWith(QLatin1String("//"))) {
executed: }
Execution Count:1
evaluated: deslashified.startsWith(QLatin1String("//"))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2035
1-2035
3504 // magic for shared drive on windows -
3505 int indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2);
executed (the execution status of this line is deduced): int indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2);
-
3506 url.setHost(deslashified.mid(2, indexOfPath - 2));
executed (the execution status of this line is deduced): url.setHost(deslashified.mid(2, indexOfPath - 2));
-
3507 if (indexOfPath > 2)
evaluated: indexOfPath > 2
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
3508 deslashified = deslashified.right(deslashified.length() - indexOfPath);
executed: deslashified = deslashified.right(deslashified.length() - indexOfPath);
Execution Count:2
2
3509 else -
3510 deslashified.clear();
executed: deslashified.clear();
Execution Count:1
1
3511 } -
3512 -
3513 url.setPath(deslashified, DecodedMode);
executed (the execution status of this line is deduced): url.setPath(deslashified, DecodedMode);
-
3514 return url;
executed: return url;
Execution Count:2039
2039
3515} -
3516 -
3517/*! -
3518 Returns the path of this URL formatted as a local file path. The path -
3519 returned will use forward slashes, even if it was originally created -
3520 from one with backslashes. -
3521 -
3522 If this URL contains a non-empty hostname, it will be encoded in the -
3523 returned value in the form found on SMB networks (for example, -
3524 "//servername/path/to/file.txt"). -
3525 -
3526 Note: if the path component of this URL contains a non-UTF-8 binary -
3527 sequence (such as %80), the behaviour of this function is undefined. -
3528 -
3529 \sa fromLocalFile(), isLocalFile() -
3530*/ -
3531QString QUrl::toLocalFile() const -
3532{ -
3533 // the call to isLocalFile() also ensures that we're parsed -
3534 if (!isLocalFile())
evaluated: !isLocalFile()
TRUEFALSE
yes
Evaluation Count:1035
yes
Evaluation Count:6315
1035-6315
3535 return QString();
executed: return QString();
Execution Count:1035
1035
3536 -
3537 QString tmp;
executed (the execution status of this line is deduced): QString tmp;
-
3538 QString ourPath = path(QUrl::FullyDecoded);
executed (the execution status of this line is deduced): QString ourPath = path(QUrl::FullyDecoded);
-
3539 -
3540 // magic for shared drive on windows -
3541 if (!d->host.isEmpty()) {
evaluated: !d->host.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6311
4-6311
3542 tmp = QStringLiteral("//") + host() + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/')
evaluated: ourPath.length() > 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
evaluated: ourPath.at(0) != QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-3
3543 ? QLatin1Char('/') + ourPath : ourPath);
executed (the execution status of this line is deduced): ? QLatin1Char('/') + ourPath : ourPath);
-
3544 } else {
executed: }
Execution Count:4
4
3545 tmp = ourPath;
executed (the execution status of this line is deduced): tmp = ourPath;
-
3546#ifdef Q_OS_WIN -
3547 // magic for drives on windows -
3548 if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) -
3549 tmp.remove(0, 1); -
3550#endif -
3551 }
executed: }
Execution Count:6311
6311
3552 return tmp;
executed: return tmp;
Execution Count:6315
6315
3553} -
3554 -
3555/*! -
3556 \since 4.8 -
3557 Returns true if this URL is pointing to a local file path. A URL is a -
3558 local file path if the scheme is "file". -
3559 -
3560 Note that this function considers URLs with hostnames to be local file -
3561 paths, even if the eventual file path cannot be opened with -
3562 QFile::open(). -
3563 -
3564 \sa fromLocalFile(), toLocalFile() -
3565*/ -
3566bool QUrl::isLocalFile() const -
3567{ -
3568 if (!d) return false;
executed: return false;
Execution Count:3
evaluated: !d
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:10129
3-10129
3569 -
3570 if (d->scheme != fileScheme())
evaluated: d->scheme != fileScheme()
TRUEFALSE
yes
Evaluation Count:3104
yes
Evaluation Count:7030
3104-7030
3571 return false; // not file
executed: return false;
Execution Count:3102
3102
3572 return true;
executed: return true;
Execution Count:7030
7030
3573} -
3574 -
3575/*! -
3576 Returns true if this URL is a parent of \a childUrl. \a childUrl is a child -
3577 of this URL if the two URLs share the same scheme and authority, -
3578 and this URL's path is a parent of the path of \a childUrl. -
3579*/ -
3580bool QUrl::isParentOf(const QUrl &childUrl) const -
3581{ -
3582 QString childPath = childUrl.path();
executed (the execution status of this line is deduced): QString childPath = childUrl.path();
-
3583 -
3584 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
3585 return ((childUrl.scheme().isEmpty())
never executed: return ((childUrl.scheme().isEmpty()) && (childUrl.authority().isEmpty()) && childPath.length() > 0 && childPath.at(0) == QLatin1Char('/'));
0
3586 && (childUrl.authority().isEmpty())
never executed: return ((childUrl.scheme().isEmpty()) && (childUrl.authority().isEmpty()) && childPath.length() > 0 && childPath.at(0) == QLatin1Char('/'));
0
3587 && childPath.length() > 0 && childPath.at(0) == QLatin1Char('/'));
never executed: return ((childUrl.scheme().isEmpty()) && (childUrl.authority().isEmpty()) && childPath.length() > 0 && childPath.at(0) == QLatin1Char('/'));
0
3588 -
3589 QString ourPath = path();
executed (the execution status of this line is deduced): QString ourPath = path();
-
3590 -
3591 return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme())
executed: return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length()) || (!ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
Execution Count:5
5
3592 && (childUrl.authority().isEmpty() || authority() == childUrl.authority())
executed: return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length()) || (!ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
Execution Count:5
5
3593 && childPath.startsWith(ourPath)
executed: return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length()) || (!ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
Execution Count:5
5
3594 && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length())
executed: return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length()) || (!ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
Execution Count:5
5
3595 || (!ourPath.endsWith(QLatin1Char('/'))
executed: return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length()) || (!ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
Execution Count:5
5
3596 && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
executed: return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme()) && (childUrl.authority().isEmpty() || authority() == childUrl.authority()) && childPath.startsWith(ourPath) && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length()) || (!ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
Execution Count:5
5
3597} -
3598 -
3599 -
3600#ifndef QT_NO_DATASTREAM -
3601/*! \relates QUrl -
3602 -
3603 Writes url \a url to the stream \a out and returns a reference -
3604 to the stream. -
3605 -
3606 \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -
3607*/ -
3608QDataStream &operator<<(QDataStream &out, const QUrl &url) -
3609{ -
3610 QByteArray u;
executed (the execution status of this line is deduced): QByteArray u;
-
3611 if (url.isValid())
evaluated: url.isValid()
TRUEFALSE
yes
Evaluation Count:474
yes
Evaluation Count:5
5-474
3612 u = url.toEncoded();
executed: u = url.toEncoded();
Execution Count:474
474
3613 out << u;
executed (the execution status of this line is deduced): out << u;
-
3614 return out;
executed: return out;
Execution Count:479
479
3615} -
3616 -
3617/*! \relates QUrl -
3618 -
3619 Reads a url into \a url from the stream \a in and returns a -
3620 reference to the stream. -
3621 -
3622 \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -
3623*/ -
3624QDataStream &operator>>(QDataStream &in, QUrl &url) -
3625{ -
3626 QByteArray u;
executed (the execution status of this line is deduced): QByteArray u;
-
3627 in >> u;
executed (the execution status of this line is deduced): in >> u;
-
3628 url.setUrl(QString::fromLatin1(u));
executed (the execution status of this line is deduced): url.setUrl(QString::fromLatin1(u));
-
3629 return in;
executed: return in;
Execution Count:309
309
3630} -
3631#endif // QT_NO_DATASTREAM -
3632 -
3633#ifndef QT_NO_DEBUG_STREAM -
3634QDebug operator<<(QDebug d, const QUrl &url) -
3635{ -
3636 d.maybeSpace() << "QUrl(" << url.toDisplayString() << ')';
executed (the execution status of this line is deduced): d.maybeSpace() << "QUrl(" << url.toDisplayString() << ')';
-
3637 return d.space();
executed: return d.space();
Execution Count:1
1
3638} -
3639#endif -
3640 -
3641static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &errorSource, int errorPosition) -
3642{ -
3643 QChar c = uint(errorPosition) < uint(errorSource.length()) ?
evaluated: uint(errorPosition) < uint(errorSource.length())
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:24
24-88
3644 errorSource.at(errorPosition) : QChar(QChar::Null);
executed (the execution status of this line is deduced): errorSource.at(errorPosition) : QChar(QChar::Null);
-
3645 -
3646 switch (errorCode) { -
3647 case QUrlPrivate::NoError: -
3648 Q_ASSERT_X(false, "QUrl::errorString",
never executed (the execution status of this line is deduced): qt_noop();
-
3649 "Impossible: QUrl::errorString should have treated this condition"); -
3650 Q_UNREACHABLE();
never executed: }
never evaluated: 0
0
3651 return QString();
never executed: return QString();
0
3652 -
3653 case QUrlPrivate::InvalidSchemeError: { -
3654 QString msg = QStringLiteral("Invalid scheme (character '%1' not permitted)");
never executed (the execution status of this line is deduced): QString msg = QString::fromUtf8("" "Invalid scheme (character '%1' not permitted)" "", sizeof("Invalid scheme (character '%1' not permitted)") - 1);
-
3655 return msg.arg(c);
never executed: return msg.arg(c);
0
3656 } -
3657 -
3658 case QUrlPrivate::InvalidUserNameError: -
3659 return QString(QStringLiteral("Invalid user name (character '%1' not permitted)"))
executed: return QString(QString::fromUtf8("" "Invalid user name (character '%1' not permitted)" "", sizeof("Invalid user name (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:10
10
3660 .arg(c);
executed: return QString(QString::fromUtf8("" "Invalid user name (character '%1' not permitted)" "", sizeof("Invalid user name (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:10
10
3661 -
3662 case QUrlPrivate::InvalidPasswordError: -
3663 return QString(QStringLiteral("Invalid password (character '%1' not permitted)"))
executed: return QString(QString::fromUtf8("" "Invalid password (character '%1' not permitted)" "", sizeof("Invalid password (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:5
5
3664 .arg(c);
executed: return QString(QString::fromUtf8("" "Invalid password (character '%1' not permitted)" "", sizeof("Invalid password (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:5
5
3665 -
3666 case QUrlPrivate::InvalidRegNameError: -
3667 if (errorPosition != -1)
partially evaluated: errorPosition != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
3668 return QString(QStringLiteral("Invalid hostname (character '%1' not permitted)"))
never executed: return QString(QString::fromUtf8("" "Invalid hostname (character '%1' not permitted)" "", sizeof("Invalid hostname (character '%1' not permitted)") - 1)) .arg(c);
0
3669 .arg(c);
never executed: return QString(QString::fromUtf8("" "Invalid hostname (character '%1' not permitted)" "", sizeof("Invalid hostname (character '%1' not permitted)") - 1)) .arg(c);
0
3670 else -
3671 return QStringLiteral("Invalid hostname (contains invalid characters)");
executed: return QString::fromUtf8("" "Invalid hostname (contains invalid characters)" "", sizeof("Invalid hostname (contains invalid characters)") - 1);
Execution Count:14
14
3672 case QUrlPrivate::InvalidIPv4AddressError: -
3673 return QString(); // doesn't happen yet
never executed: return QString();
0
3674 case QUrlPrivate::InvalidIPv6AddressError: -
3675 return QStringLiteral("Invalid IPv6 address");
executed: return QString::fromUtf8("" "Invalid IPv6 address" "", sizeof("Invalid IPv6 address") - 1);
Execution Count:5
5
3676 case QUrlPrivate::InvalidIPvFutureError: -
3677 return QStringLiteral("Invalid IPvFuture address");
executed: return QString::fromUtf8("" "Invalid IPvFuture address" "", sizeof("Invalid IPvFuture address") - 1);
Execution Count:15
15
3678 case QUrlPrivate::HostMissingEndBracket: -
3679 return QStringLiteral("Expected ']' to match '[' in hostname");
executed: return QString::fromUtf8("" "Expected ']' to match '[' in hostname" "", sizeof("Expected ']' to match '[' in hostname") - 1);
Execution Count:5
5
3680 -
3681 case QUrlPrivate::InvalidPortError: -
3682 return QStringLiteral("Invalid port or port number out of range");
executed: return QString::fromUtf8("" "Invalid port or port number out of range" "", sizeof("Invalid port or port number out of range") - 1);
Execution Count:21
21
3683 case QUrlPrivate::PortEmptyError: -
3684 return QStringLiteral("Port field was empty");
executed: return QString::fromUtf8("" "Port field was empty" "", sizeof("Port field was empty") - 1);
Execution Count:10
10
3685 -
3686 case QUrlPrivate::InvalidPathError: -
3687 return QString(QStringLiteral("Invalid path (character '%1' not permitted)"))
executed: return QString(QString::fromUtf8("" "Invalid path (character '%1' not permitted)" "", sizeof("Invalid path (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:10
10
3688 .arg(c);
executed: return QString(QString::fromUtf8("" "Invalid path (character '%1' not permitted)" "", sizeof("Invalid path (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:10
10
3689 -
3690 case QUrlPrivate::InvalidQueryError: -
3691 return QString(QStringLiteral("Invalid query (character '%1' not permitted)"))
executed: return QString(QString::fromUtf8("" "Invalid query (character '%1' not permitted)" "", sizeof("Invalid query (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:5
5
3692 .arg(c);
executed: return QString(QString::fromUtf8("" "Invalid query (character '%1' not permitted)" "", sizeof("Invalid query (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:5
5
3693 -
3694 case QUrlPrivate::InvalidFragmentError: -
3695 return QString(QStringLiteral("Invalid fragment (character '%1' not permitted)"))
executed: return QString(QString::fromUtf8("" "Invalid fragment (character '%1' not permitted)" "", sizeof("Invalid fragment (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:5
5
3696 .arg(c);
executed: return QString(QString::fromUtf8("" "Invalid fragment (character '%1' not permitted)" "", sizeof("Invalid fragment (character '%1' not permitted)") - 1)) .arg(c);
Execution Count:5
5
3697 -
3698 case QUrlPrivate::AuthorityPresentAndPathIsRelative: -
3699 return QStringLiteral("Path component is relative and authority is present");
executed: return QString::fromUtf8("" "Path component is relative and authority is present" "", sizeof("Path component is relative and authority is present") - 1);
Execution Count:1
1
3700 case QUrlPrivate::RelativeUrlPathContainsColonBeforeSlash: -
3701 return QStringLiteral("Relative URL's path component contains ':' before any '/'");
executed: return QString::fromUtf8("" "Relative URL's path component contains ':' before any '/'" "", sizeof("Relative URL's path component contains ':' before any '/'") - 1);
Execution Count:6
6
3702 } -
3703 -
3704 Q_ASSERT_X(false, "QUrl::errorString", "Cannot happen, unknown error");
never executed (the execution status of this line is deduced): qt_noop();
-
3705 Q_UNREACHABLE();
never executed: }
never evaluated: 0
0
3706 return QString();
never executed: return QString();
0
3707} -
3708 -
3709static inline void appendComponentIfPresent(QString &msg, bool present, const char *componentName, -
3710 const QString &component) -
3711{ -
3712 if (present) {
evaluated: present
TRUEFALSE
yes
Evaluation Count:216
yes
Evaluation Count:568
216-568
3713 msg += QLatin1String(componentName);
executed (the execution status of this line is deduced): msg += QLatin1String(componentName);
-
3714 msg += QLatin1Char('"');
executed (the execution status of this line is deduced): msg += QLatin1Char('"');
-
3715 msg += component;
executed (the execution status of this line is deduced): msg += component;
-
3716 msg += QLatin1String("\",");
executed (the execution status of this line is deduced): msg += QLatin1String("\",");
-
3717 }
executed: }
Execution Count:216
216
3718}
executed: }
Execution Count:784
784
3719 -
3720/*! -
3721 \since 4.2 -
3722 -
3723 Returns an error message if the last operation that modified this QUrl -
3724 object ran into a parsing error. If no error was detected, this function -
3725 returns an empty string and isValid() returns true. -
3726 -
3727 The error message returned by this function is technical in nature and may -
3728 not be understood by end users. It is mostly useful to developers trying to -
3729 understand why QUrl will not accept some input. -
3730 -
3731 \sa QUrl::ParsingMode -
3732*/ -
3733QString QUrl::errorString() const -
3734{ -
3735 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:114
22-114
3736 return QString();
executed: return QString();
Execution Count:22
22
3737 -
3738 QString errorSource;
executed (the execution status of this line is deduced): QString errorSource;
-
3739 int errorPosition;
executed (the execution status of this line is deduced): int errorPosition;
-
3740 QUrlPrivate::ErrorCode errorCode = d->validityError(&errorSource, &errorPosition);
executed (the execution status of this line is deduced): QUrlPrivate::ErrorCode errorCode = d->validityError(&errorSource, &errorPosition);
-
3741 if (errorCode == QUrlPrivate::NoError)
evaluated: errorCode == QUrlPrivate::NoError
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:112
2-112
3742 return QString();
executed: return QString();
Execution Count:2
2
3743 -
3744 QString msg = errorMessage(errorCode, errorSource, errorPosition);
executed (the execution status of this line is deduced): QString msg = errorMessage(errorCode, errorSource, errorPosition);
-
3745 msg += QLatin1String("; source was \"");
executed (the execution status of this line is deduced): msg += QLatin1String("; source was \"");
-
3746 msg += errorSource;
executed (the execution status of this line is deduced): msg += errorSource;
-
3747 msg += QLatin1String("\";");
executed (the execution status of this line is deduced): msg += QLatin1String("\";");
-
3748 appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Scheme,
executed (the execution status of this line is deduced): appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Scheme,
-
3749 " scheme = ", d->scheme);
executed (the execution status of this line is deduced): " scheme = ", d->scheme);
-
3750 appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::UserInfo,
executed (the execution status of this line is deduced): appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::UserInfo,
-
3751 " userinfo = ", userInfo());
executed (the execution status of this line is deduced): " userinfo = ", userInfo());
-
3752 appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Host,
executed (the execution status of this line is deduced): appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Host,
-
3753 " host = ", d->host);
executed (the execution status of this line is deduced): " host = ", d->host);
-
3754 appendComponentIfPresent(msg, d->port != -1,
executed (the execution status of this line is deduced): appendComponentIfPresent(msg, d->port != -1,
-
3755 " port = ", QString::number(d->port));
executed (the execution status of this line is deduced): " port = ", QString::number(d->port));
-
3756 appendComponentIfPresent(msg, !d->path.isEmpty(),
executed (the execution status of this line is deduced): appendComponentIfPresent(msg, !d->path.isEmpty(),
-
3757 " path = ", d->path);
executed (the execution status of this line is deduced): " path = ", d->path);
-
3758 appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Query,
executed (the execution status of this line is deduced): appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Query,
-
3759 " query = ", d->query);
executed (the execution status of this line is deduced): " query = ", d->query);
-
3760 appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Fragment,
executed (the execution status of this line is deduced): appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Fragment,
-
3761 " fragment = ", d->fragment);
executed (the execution status of this line is deduced): " fragment = ", d->fragment);
-
3762 if (msg.endsWith(QLatin1Char(',')))
evaluated: msg.endsWith(QLatin1Char(','))
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:1
1-111
3763 msg.chop(1);
executed: msg.chop(1);
Execution Count:111
111
3764 return msg;
executed: return msg;
Execution Count:112
112
3765} -
3766 -
3767/*! -
3768 \typedef QUrl::DataPtr -
3769 \internal -
3770*/ -
3771 -
3772/*! -
3773 \fn DataPtr &QUrl::data_ptr() -
3774 \internal -
3775*/ -
3776 -
3777/*! -
3778 Returns the hash value for the \a url. If specified, \a seed is used to -
3779 initialize the hash. -
3780 -
3781 \relates QHash -
3782 \since 5.0 -
3783*/ -
3784uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW -
3785{ -
3786 if (!url.d)
evaluated: !url.d
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
3-7
3787 return qHash(-1, seed); // the hash of an unset port (-1)
executed: return qHash(-1, seed);
Execution Count:3
3
3788 -
3789 return qHash(url.d->scheme) ^
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3790 qHash(url.d->userName) ^
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3791 qHash(url.d->password) ^
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3792 qHash(url.d->host) ^
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3793 qHash(url.d->port, seed) ^
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3794 qHash(url.d->path) ^
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3795 qHash(url.d->query) ^
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3796 qHash(url.d->fragment);
executed: return qHash(url.d->scheme) ^ qHash(url.d->userName) ^ qHash(url.d->password) ^ qHash(url.d->host) ^ qHash(url.d->port, seed) ^ qHash(url.d->path) ^ qHash(url.d->query) ^ qHash(url.d->fragment);
Execution Count:7
7
3797} -
3798 -
3799static QUrl adjustFtpPath(QUrl url) -
3800{ -
3801 if (url.scheme() == ftpScheme()) {
evaluated: url.scheme() == ftpScheme()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:24
3-24
3802 QString path = url.path();
executed (the execution status of this line is deduced): QString path = url.path();
-
3803 if (path.startsWith(QLatin1String("//")))
evaluated: path.startsWith(QLatin1String("//"))
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
3804 url.setPath(QLatin1String("/%2F") + path.midRef(2));
executed: url.setPath(QLatin1String("/%2F") + path.midRef(2));
Execution Count:2
2
3805 }
executed: }
Execution Count:3
3
3806 return url;
executed: return url;
Execution Count:27
27
3807} -
3808 -
3809 -
3810// The following code has the following copyright: -
3811/* -
3812 Copyright (C) Research In Motion Limited 2009. All rights reserved. -
3813 -
3814Redistribution and use in source and binary forms, with or without -
3815modification, are permitted provided that the following conditions are met: -
3816 * Redistributions of source code must retain the above copyright -
3817 notice, this list of conditions and the following disclaimer. -
3818 * Redistributions in binary form must reproduce the above copyright -
3819 notice, this list of conditions and the following disclaimer in the -
3820 documentation and/or other materials provided with the distribution. -
3821 * Neither the name of Research In Motion Limited nor the -
3822 names of its contributors may be used to endorse or promote products -
3823 derived from this software without specific prior written permission. -
3824 -
3825THIS SOFTWARE IS PROVIDED BY Research In Motion Limited ''AS IS'' AND ANY -
3826EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -
3827WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -
3828DISCLAIMED. IN NO EVENT SHALL Research In Motion Limited BE LIABLE FOR ANY -
3829DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -
3830(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -
3831LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -
3832ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -
3833(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -
3834SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -
3835 -
3836*/ -
3837 -
3838 -
3839/*! -
3840 Returns a valid URL from a user supplied \a userInput string if one can be -
3841 deducted. In the case that is not possible, an invalid QUrl() is returned. -
3842 -
3843 \since 4.6 -
3844 -
3845 Most applications that can browse the web, allow the user to input a URL -
3846 in the form of a plain string. This string can be manually typed into -
3847 a location bar, obtained from the clipboard, or passed in via command -
3848 line arguments. -
3849 -
3850 When the string is not already a valid URL, a best guess is performed, -
3851 making various web related assumptions. -
3852 -
3853 In the case the string corresponds to a valid file path on the system, -
3854 a file:// URL is constructed, using QUrl::fromLocalFile(). -
3855 -
3856 If that is not the case, an attempt is made to turn the string into a -
3857 http:// or ftp:// URL. The latter in the case the string starts with -
3858 'ftp'. The result is then passed through QUrl's tolerant parser, and -
3859 in the case or success, a valid QUrl is returned, or else a QUrl(). -
3860 -
3861 \section1 Examples: -
3862 -
3863 \list -
3864 \li qt-project.org becomes http://qt-project.org -
3865 \li ftp.qt-project.org becomes ftp://ftp.qt-project.org -
3866 \li hostname becomes http://hostname -
3867 \li /home/user/test.html becomes file:///home/user/test.html -
3868 \endlist -
3869*/ -
3870QUrl QUrl::fromUserInput(const QString &userInput) -
3871{ -
3872 QString trimmedString = userInput.trimmed();
executed (the execution status of this line is deduced): QString trimmedString = userInput.trimmed();
-
3873 -
3874 // Check first for files, since on Windows drive letters can be interpretted as schemes -
3875 if (QDir::isAbsolutePath(trimmedString))
evaluated: QDir::isAbsolutePath(trimmedString)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:28
7-28
3876 return QUrl::fromLocalFile(trimmedString);
executed: return QUrl::fromLocalFile(trimmedString);
Execution Count:7
7
3877 -
3878 QUrl url = QUrl(trimmedString, QUrl::TolerantMode);
executed (the execution status of this line is deduced): QUrl url = QUrl(trimmedString, QUrl::TolerantMode);
-
3879 QUrl urlPrepended = QUrl(QStringLiteral("http://") + trimmedString, QUrl::TolerantMode);
executed (the execution status of this line is deduced): QUrl urlPrepended = QUrl(QString::fromUtf8("" "http://" "", sizeof("http://") - 1) + trimmedString, QUrl::TolerantMode);
-
3880 -
3881 // Check the most common case of a valid url with a scheme -
3882 // We check if the port would be valid by adding the scheme to handle the case host:port -
3883 // where the host would be interpretted as the scheme -
3884 if (url.isValid()
evaluated: url.isValid()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:1
1-27
3885 && !url.scheme().isEmpty()
evaluated: !url.scheme().isEmpty()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:12
12-15
3886 && urlPrepended.port() == -1)
evaluated: urlPrepended.port() == -1
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3
3-12
3887 return adjustFtpPath(url);
executed: return adjustFtpPath(url);
Execution Count:12
12
3888 -
3889 // Else, try the prepended one and adjust the scheme from the host name -
3890 if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty()))
partially evaluated: urlPrepended.isValid()
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
evaluated: !urlPrepended.host().isEmpty()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1
partially evaluated: !urlPrepended.path().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-16
3891 { -
3892 int dotIndex = trimmedString.indexOf(QLatin1Char('.'));
executed (the execution status of this line is deduced): int dotIndex = trimmedString.indexOf(QLatin1Char('.'));
-
3893 const QString hostscheme = trimmedString.left(dotIndex).toLower();
executed (the execution status of this line is deduced): const QString hostscheme = trimmedString.left(dotIndex).toLower();
-
3894 if (hostscheme == ftpScheme())
evaluated: hostscheme == ftpScheme()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:13
2-13
3895 urlPrepended.setScheme(ftpScheme());
executed: urlPrepended.setScheme(ftpScheme());
Execution Count:2
2
3896 return adjustFtpPath(urlPrepended);
executed: return adjustFtpPath(urlPrepended);
Execution Count:15
15
3897 } -
3898 -
3899 return QUrl();
executed: return QUrl();
Execution Count:1
1
3900} -
3901// end of BSD code -
3902 -
3903QT_END_NAMESPACE -
3904 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial