diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-07-31 14:28:48 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-01 13:04:18 +0200 |
commit | e1038794b1d7fe298535960eb90d5c823aa3f2c4 (patch) | |
tree | 02f152e85fc942fa17239db3c5c4ac0ebe5d8651 /src | |
parent | f893d9ec41578c0981507dccc41d1ee2a11f6bae (diff) |
Make QUrl::setScheme only parse in strict mode (no decoding)
The URI RFC defines schemes as containing only a very restricted set
of characters, none of which require encoding, so don't even
try. Testing this behaviour in some web browsers indicate that they do
not accept percent-encoded schemes either.
Change-Id: I692dd20e1aac7e8a1bcb276cb5113b5802393d38
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qurl.cpp | 17 | ||||
-rw-r--r-- | src/corelib/io/qurl_p.h | 2 |
2 files changed, 3 insertions, 16 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index ff1f7ba78c..bc92e943fc 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -656,7 +656,7 @@ inline void QUrlPrivate::appendQuery(QString &appendTo, QUrl::FormattingOptions // setXXX functions -bool QUrlPrivate::setScheme(const QString &value, int len, bool decoded) +bool QUrlPrivate::setScheme(const QString &value, int len) { // schemes are strictly RFC-compliant: // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) @@ -687,19 +687,6 @@ bool QUrlPrivate::setScheme(const QString &value, int len, bool decoded) if (p[i] == '+' || p[i] == '-' || p[i] == '.') continue; - if (p[i] == '%') { - // found a percent-encoded sign - // if we haven't decoded yet, decode and try again - errorSupplement = '%'; - if (decoded) - return false; - - QString decodedScheme; - if (qt_urlRecode(decodedScheme, value.constData(), value.constData() + len, 0, 0) == 0) - return false; - return setScheme(decodedScheme, decodedScheme.length(), true); - } - // found something else errorSupplement = p[i]; return false; @@ -1581,7 +1568,7 @@ void QUrl::setUrl(const QString &url, ParsingMode parsingMode) /*! Sets the scheme of the URL to \a scheme. As a scheme can only - contain ASCII characters, no conversion or encoding is done on the + contain ASCII characters, no conversion or decoding is done on the input. It must also start with an ASCII letter. The scheme describes the type (or protocol) of the URL. It's diff --git a/src/corelib/io/qurl_p.h b/src/corelib/io/qurl_p.h index 3a0d80d7ef..95ccd221a2 100644 --- a/src/corelib/io/qurl_p.h +++ b/src/corelib/io/qurl_p.h @@ -122,7 +122,7 @@ public: void appendFragment(QString &appendTo, QUrl::FormattingOptions options) const; // the "end" parameters are like STL iterators: they point to one past the last valid element - bool setScheme(const QString &value, int len, bool decoded = false); + bool setScheme(const QString &value, int len); bool setAuthority(const QString &auth, int from, int end); void setUserInfo(const QString &userInfo, int from, int end); void setUserName(const QString &value, int from, int end); |