summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolina Gomes <ext-carolina.s.gomes@nomovok.com>2010-02-25 15:30:47 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-02-25 15:32:34 (GMT)
commit4b119820089b35aaba061936eded882e0ac96a97 (patch)
tree28dd0bd4c9289ea5f7119778820f495c8a60dafc
parent20aba4ffa2fdf7a7306424981049d430f7d88e5c (diff)
downloadQt-4b119820089b35aaba061936eded882e0ac96a97.zip
Qt-4b119820089b35aaba061936eded882e0ac96a97.tar.gz
Qt-4b119820089b35aaba061936eded882e0ac96a97.tar.bz2
Patch to QTBUG-3168
Patch to QTBUG-3168 and update tst_qurl to enable the test case that was skipped. Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
-rw-r--r--src/corelib/io/qurl.cpp27
-rw-r--r--tests/auto/qurl/tst_qurl.cpp3
2 files changed, 22 insertions, 8 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 076cc33..05d043e 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -437,17 +437,19 @@ static bool QT_FASTCALL _unreserved(const char **ptr)
}
// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
-static void QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
+static bool QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
{
bool first = true;
-
+ bool isSchemeValid = true;
+
parseData->scheme = *ptr;
for (;;) {
char ch = **ptr;
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
;
- } else if (!first && ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.')) {
- ;
+ } else if ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') {
+ if (first)
+ isSchemeValid = false;
} else {
break;
}
@@ -457,11 +459,14 @@ static void QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
}
if (**ptr != ':') {
+ isSchemeValid = true;
*ptr = parseData->scheme;
} else {
parseData->schemeLength = *ptr - parseData->scheme;
++(*ptr); // skip ':'
}
+
+ return isSchemeValid;
}
// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
@@ -3743,7 +3748,19 @@ void QUrlPrivate::parse(ParseOptions parseOptions) const
#endif
// optional scheme
- _scheme(ptr, &parseData);
+ bool isSchemeValid = _scheme(ptr, &parseData);
+
+ if (isSchemeValid == false) {
+ that->isValid = false;
+ char ch = *((*ptr)++);
+ that->errorInfo.setParams(*ptr, QT_TRANSLATE_NOOP(QUrl, "unexpected URL scheme"),
+ 0, ch);
+ QURL_SETFLAG(that->stateFlags, Validated | Parsed);
+#if defined (QURL_DEBUG)
+ qDebug("QUrlPrivate::parse(), unrecognized: %c%s", ch, *ptr);
+#endif
+ return;
+ }
// hierpart
_hierPart(ptr, &parseData);
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 72ce393..bc5a0af 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -2513,9 +2513,6 @@ void tst_QUrl::schemeValidator()
void tst_QUrl::invalidSchemeValidator()
{
- // enable that test when QUrl is fixed
- return;
-
// test that if scheme does not start with an ALPHA, QUrl::isValid() returns false
{
QUrl url("1http://qt.nokia.com", QUrl::StrictMode);