Hi,
Before using regular expressions to validate a link I tried QUrl::isValid() and expected it to tell me when an url is not valid, just as a browser like konqi would throw an error message like "malformed url" with a big red error icon at me leaving no doubt that I shouldn't try this again. QUrl::isValid() however kindly waves through anything I pass to it except an empty string.

The documentation says this:
The URL is run through a conformance test. Every part of the URL must conform to the standard encoding rules of the URI standard for the URL to be reported as valid.
The conformance encoding rules seem to be pretty lax.
Why is that?

Here is an example:

Qt Code:
  1. #include <QtGui>
  2.  
  3. int main()
  4. {
  5. QList<QUrl> urls;
  6. urls << QUrl()
  7. << QUrl(" ")
  8. << QUrl("http://google.de")
  9. << QUrl("++ !! 3w27 WHY AM I VALID? 64a.sdk).d.d.d:/77(8*euiafds");
  10.  
  11. foreach (const QUrl url, urls) {
  12. qDebug() << "is " << url << "valid? Answer: " << url.isValid();
  13. }
  14. }
To copy to clipboard, switch view to plain text mode 

Thanx in advance