summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-05-21 15:14:40 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-22 20:56:38 +0200
commit239dd9fef153286832c853eefb9fc075a1eafbe3 (patch)
treee09486d925a38dbe8642a95279a6a2679ba4c1d7 /src/corelib
parentf0ec001242228bd6ee73ca320a82365a3f9323aa (diff)
Add the QUrl::DecodedMode parsing mode
This mode will be used to support parsing of URL components in their fully-decoded forms. It is not permitted when parsing the full URL, as that would be ambiguous. Change-Id: Id8d39a740845ae8d1efef894085280b322e39c0a Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qurl.cpp23
-rw-r--r--src/corelib/io/qurl.h3
2 files changed, 20 insertions, 6 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 319de070ee..bb97890d15 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -132,6 +132,12 @@
\value StrictMode Only valid URLs are accepted. This mode is useful for
general URL validation.
+ \value DecodedMode QUrl will interpret the URL component in the fully-decoded form,
+ where percent characters stand for themselves, not as the beginning
+ of a percent-encoded sequence. This mode is only valid for the
+ setters setting components of a URL; it is not permitted in
+ the QUrl constructor, in fromEncoded() or in setUrl().
+
In TolerantMode, the parser has the following behaviour:
\list
@@ -1460,7 +1466,8 @@ const QByteArray &QUrlPrivate::normalized() const
will accept any character in any position. In StrictMode, encoding mistakes
will not be tolerated and QUrl will also check that certain forbidden
characters are not present in unencoded form. If an error is detected in
- StrictMode, isValid() will return false.
+ StrictMode, isValid() will return false. The parsing mode DecodedMode is not
+ permitted in this context.
Example:
@@ -1550,14 +1557,19 @@ void QUrl::clear()
will accept any character in any position. In StrictMode, encoding mistakes
will not be tolerated and QUrl will also check that certain forbidden
characters are not present in unencoded form. If an error is detected in
- StrictMode, isValid() will return false.
+ StrictMode, isValid() will return false. The parsing mode DecodedMode is
+ not permitted in this context and will produce a run-time warning.
\sa setEncodedUrl()
*/
void QUrl::setUrl(const QString &url, ParsingMode parsingMode)
{
- detach();
- d->parse(url, parsingMode);
+ if (parsingMode == DecodedMode) {
+ qWarning("QUrl: QUrl::DecodedMode is not permitted when parsing a full URL");
+ } else {
+ detach();
+ d->parse(url, parsingMode);
+ }
}
@@ -2219,7 +2231,8 @@ QByteArray QUrl::toEncoded(FormattingOptions options) const
Parses \a input and returns the corresponding QUrl. \a input is
assumed to be in encoded form, containing only ASCII characters.
- Parses the URL using \a parsingMode.
+ Parses the URL using \a parsingMode. See setUrl() for more information on
+ this parameter. QUrl::DecodedMode is not permitted in this context.
\sa toEncoded(), setUrl()
*/
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 79968e5587..533489ae2b 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -118,7 +118,8 @@ class Q_CORE_EXPORT QUrl
public:
enum ParsingMode {
TolerantMode,
- StrictMode
+ StrictMode,
+ DecodedMode
};
// encoding / toString values