diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2019-08-20 14:59:09 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2019-10-10 12:33:32 +0200 |
commit | f5dcde6c5053fde1d0788f1462c53522082a56e1 (patch) | |
tree | e1d16e76f8a943e6fe5ef2813de50da9c8dd92b1 /src | |
parent | af8b508de56fee70d6f3c971254fcb848805d18f (diff) | |
download | qtxmlpatterns-f5dcde6c5053fde1d0788f1462c53522082a56e1.tar.gz |
Fix loading of schemas and validation to use resolved URLsv5.14.0-beta2
Loading the scheme did compute and record a resolved URL, but didn't
actually pass it on, so a QUrl() of a plain local path (which is
unresolved so doesn't know it's local) isn't recognized by QNAM as
being local when it decides how to handle the request it's been sent.
Likewise, verification's loading of files used the URL it was given,
without resolving, so would fail to read local files it was meant to
validate.
This lead to getting no data from local files. (That, in turn,
prevented a new test-case I'm about to add from crashing, which the
same change shall fix.)
Change-Id: Icc56dd599897d3498f0838b2f12e3ac46da84519
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/xmlpatterns/api/qxmlschema_p.cpp | 6 | ||||
-rw-r--r-- | src/xmlpatterns/api/qxmlschemavalidator.cpp | 13 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/xmlpatterns/api/qxmlschema_p.cpp b/src/xmlpatterns/api/qxmlschema_p.cpp index d87b465..30cadd7 100644 --- a/src/xmlpatterns/api/qxmlschema_p.cpp +++ b/src/xmlpatterns/api/qxmlschema_p.cpp @@ -97,8 +97,10 @@ void QXmlSchemaPrivate::load(const QUrl &source, const QString &targetNamespace) m_schemaContext->setUriResolver(uriResolver()); m_schemaContext->setNetworkAccessManager(networkAccessManager()); - const QPatternist::AutoPtr<QNetworkReply> reply(QPatternist::AccelTreeResourceLoader::load(source, m_schemaContext->networkAccessManager(), - m_schemaContext, QPatternist::AccelTreeResourceLoader::ContinueOnError)); + const QPatternist::AutoPtr<QNetworkReply> reply( + QPatternist::AccelTreeResourceLoader::load( + m_documentUri, m_schemaContext->networkAccessManager(), + m_schemaContext, QPatternist::AccelTreeResourceLoader::ContinueOnError)); if (reply) load(reply.data(), source, targetNamespace); } diff --git a/src/xmlpatterns/api/qxmlschemavalidator.cpp b/src/xmlpatterns/api/qxmlschemavalidator.cpp index f4a25df..112d780 100644 --- a/src/xmlpatterns/api/qxmlschemavalidator.cpp +++ b/src/xmlpatterns/api/qxmlschemavalidator.cpp @@ -154,13 +154,14 @@ bool QXmlSchemaValidator::validate(const QUrl &source) const d->m_context->setMessageHandler(messageHandler()); d->m_context->setUriResolver(uriResolver()); d->m_context->setNetworkAccessManager(networkAccessManager()); + const QUrl resolved = QPatternist::XPathHelper::normalizeQueryURI(source); - const QPatternist::AutoPtr<QNetworkReply> reply(QPatternist::AccelTreeResourceLoader::load(source, d->m_context->networkAccessManager(), - d->m_context, QPatternist::AccelTreeResourceLoader::ContinueOnError)); - if (reply) - return validate(reply.data(), source); - else - return false; + const QPatternist::AutoPtr<QNetworkReply> reply( + QPatternist::AccelTreeResourceLoader::load( + resolved, d->m_context->networkAccessManager(), + d->m_context, QPatternist::AccelTreeResourceLoader::ContinueOnError)); + + return reply && validate(reply.data(), source); } /*! |