diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-03-23 04:51:56 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-03-23 04:51:56 (GMT) |
commit | 95aa8c8fc76e2309a629b05994a2677b0887140b (patch) | |
tree | 50d7318281610f24df5a9736906a9a6433aba7d8 /src/declarative/qml | |
parent | 9a41034cf05ad4c149e3a98dc8e39f5f6ad05d28 (diff) | |
download | Qt-95aa8c8fc76e2309a629b05994a2677b0887140b.zip Qt-95aa8c8fc76e2309a629b05994a2677b0887140b.tar.gz Qt-95aa8c8fc76e2309a629b05994a2677b0887140b.tar.bz2 |
Basic Loader origin safety (for discussion).
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qdeclarativecontext.cpp | 16 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativecontext.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 85896c4..ab3849a 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -361,6 +361,22 @@ QVariant QDeclarativeContext::contextProperty(const QString &name) const return value; } +bool QDeclarativeContext::isSafeOrigin(const QUrl &src) const +{ + if (src.isRelative()) + return true; + if (src.scheme()==QLatin1String("https")) + return true; + + QUrl base = baseUrl(); + if (src.host() == base.host() && src.port() == base.port()) // including files (with no host) + return true; + + qWarning() << src << "is not a safe origin from" << base; + + return false; +} + /*! Resolves the URL \a src relative to the URL of the containing component. diff --git a/src/declarative/qml/qdeclarativecontext.h b/src/declarative/qml/qdeclarativecontext.h index a349628..959af8b 100644 --- a/src/declarative/qml/qdeclarativecontext.h +++ b/src/declarative/qml/qdeclarativecontext.h @@ -85,6 +85,8 @@ public: void setBaseUrl(const QUrl &); QUrl baseUrl() const; + bool isSafeOrigin(const QUrl &src) const; + private: friend class QDeclarativeVME; friend class QDeclarativeEngine; |