equal
deleted
inserted
replaced
336 QUrl::ParsingMode parsingMode; |
336 QUrl::ParsingMode parsingMode; |
337 |
337 |
338 bool hasQuery; |
338 bool hasQuery; |
339 bool hasFragment; |
339 bool hasFragment; |
340 bool isValid; |
340 bool isValid; |
|
341 bool isHostValid; |
341 |
342 |
342 char valueDelimiter; |
343 char valueDelimiter; |
343 char pairDelimiter; |
344 char pairDelimiter; |
344 |
345 |
345 enum State { |
346 enum State { |
2988 |
2989 |
2989 // verifying the absence of LDH is the same as verifying that |
2990 // verifying the absence of LDH is the same as verifying that |
2990 // only LDH is present |
2991 // only LDH is present |
2991 if (c == '-' || (c >= '0' && c <= '9') |
2992 if (c == '-' || (c >= '0' && c <= '9') |
2992 || (c >= 'A' && c <= 'Z') |
2993 || (c >= 'A' && c <= 'Z') |
2993 || (c >= 'a' && c <= 'z')) |
2994 || (c >= 'a' && c <= 'z') |
|
2995 //underscore is not supposed to be allowed, but other browser accept it (QTBUG-7434) |
|
2996 || c == '_') |
2994 continue; |
2997 continue; |
2995 |
2998 |
2996 return false; |
2999 return false; |
2997 } |
3000 } |
2998 |
3001 |
3343 QUrlPrivate::QUrlPrivate() |
3346 QUrlPrivate::QUrlPrivate() |
3344 { |
3347 { |
3345 ref = 1; |
3348 ref = 1; |
3346 port = -1; |
3349 port = -1; |
3347 isValid = false; |
3350 isValid = false; |
|
3351 isHostValid = true; |
3348 parsingMode = QUrl::TolerantMode; |
3352 parsingMode = QUrl::TolerantMode; |
3349 valueDelimiter = '='; |
3353 valueDelimiter = '='; |
3350 pairDelimiter = '&'; |
3354 pairDelimiter = '&'; |
3351 stateFlags = 0; |
3355 stateFlags = 0; |
3352 hasFragment = false; |
3356 hasFragment = false; |
3369 port(copy.port), |
3373 port(copy.port), |
3370 parsingMode(copy.parsingMode), |
3374 parsingMode(copy.parsingMode), |
3371 hasQuery(copy.hasQuery), |
3375 hasQuery(copy.hasQuery), |
3372 hasFragment(copy.hasFragment), |
3376 hasFragment(copy.hasFragment), |
3373 isValid(copy.isValid), |
3377 isValid(copy.isValid), |
|
3378 isHostValid(copy.isHostValid), |
3374 valueDelimiter(copy.valueDelimiter), |
3379 valueDelimiter(copy.valueDelimiter), |
3375 pairDelimiter(copy.pairDelimiter), |
3380 pairDelimiter(copy.pairDelimiter), |
3376 stateFlags(copy.stateFlags), |
3381 stateFlags(copy.stateFlags), |
3377 encodedNormalized(copy.encodedNormalized) |
3382 encodedNormalized(copy.encodedNormalized) |
3378 { ref = 1; } |
3383 { ref = 1; } |
3399 that->host.clear(); |
3404 that->host.clear(); |
3400 else |
3405 else |
3401 that->host = host.toLower(); |
3406 that->host = host.toLower(); |
3402 } else { |
3407 } else { |
3403 that->host = qt_ACE_do(host, NormalizeAce); |
3408 that->host = qt_ACE_do(host, NormalizeAce); |
|
3409 if (that->host.isNull()) |
|
3410 that->isHostValid = false; |
3404 } |
3411 } |
3405 return that->host; |
3412 return that->host; |
3406 } |
3413 } |
3407 |
3414 |
3408 // From RFC 3896, Appendix A Collected ABNF for URI |
3415 // From RFC 3896, Appendix A Collected ABNF for URI |
3475 return tmp; |
3482 return tmp; |
3476 } |
3483 } |
3477 |
3484 |
3478 void QUrlPrivate::setAuthority(const QString &auth) |
3485 void QUrlPrivate::setAuthority(const QString &auth) |
3479 { |
3486 { |
|
3487 isHostValid = true; |
3480 if (auth.isEmpty()) |
3488 if (auth.isEmpty()) |
3481 return; |
3489 return; |
3482 |
3490 |
3483 // find the port section of the authority by searching from the |
3491 // find the port section of the authority by searching from the |
3484 // end towards the beginning for numbers until a ':' is reached. |
3492 // end towards the beginning for numbers until a ':' is reached. |
4165 if (!d) return false; |
4173 if (!d) return false; |
4166 |
4174 |
4167 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); |
4175 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); |
4168 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate(); |
4176 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate(); |
4169 |
4177 |
4170 return d->isValid; |
4178 return d->isValid && d->isHostValid; |
4171 } |
4179 } |
4172 |
4180 |
4173 /*! |
4181 /*! |
4174 Returns true if the URL has no data; otherwise returns false. |
4182 Returns true if the URL has no data; otherwise returns false. |
4175 */ |
4183 */ |
4417 if (!d) d = new QUrlPrivate; |
4425 if (!d) d = new QUrlPrivate; |
4418 |
4426 |
4419 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); |
4427 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); |
4420 detach(); |
4428 detach(); |
4421 QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized); |
4429 QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized); |
4422 |
|
4423 d->setAuthority(authority); |
4430 d->setAuthority(authority); |
4424 } |
4431 } |
4425 |
4432 |
4426 /*! |
4433 /*! |
4427 Returns the authority of the URL if it is defined; otherwise |
4434 Returns the authority of the URL if it is defined; otherwise |
4638 void QUrl::setHost(const QString &host) |
4645 void QUrl::setHost(const QString &host) |
4639 { |
4646 { |
4640 if (!d) d = new QUrlPrivate; |
4647 if (!d) d = new QUrlPrivate; |
4641 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); |
4648 if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); |
4642 detach(); |
4649 detach(); |
|
4650 d->isHostValid = true; |
4643 QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); |
4651 QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); |
4644 |
4652 |
4645 d->host = host; |
4653 d->host = host; |
4646 } |
4654 } |
4647 |
4655 |