Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-26551

Plugins loaded via qmldir can install types into arbitrary uri

    XMLWordPrintable

Details

    Description

      Currently, the qmldir file syntax does not include an import uri specification (module name). A single qmldir file can specify multiple plugins to be loaded, where these are able to install types into any namespace and any versions.

      This means that clients who import modules cannot know if that module overwrites types from other modules which is clearly incorrect.

      The qmldir syntax should be modified to allow the following:

      first line of qmldir file can be a "module" specification of the form:

      module <moduleImportNamespace>
      

      such as:

      module MyComponents
      

      Such a qmldir file is known as a "module specification file".
      Types registered by any plugin which is listed in that qmldir file must be registered into the uri/version tuple specified by the qmldir file:

      module MyComponents
      BlueRectangle 1.0 BlueRect.qml
      plugin mycomponents
      

      in the previous example, the libmycomponents.so plugin's registerTypes() function should take as args the import uri as a parameter, and QML should enforce that it doesn't register types into a different uri than what was passed in as a param.

      This sort of qmldir file specifies a "strict module specification" - types in that module's namespace cannot be overwritten by other modules, nor can other modules put more/different types into that namespace (but the user can inject types via qmlRegisterType(); only other modules are restricted). Such a module is "self contained and guaranteed pristine" since it cannot install types into other namespaces, and the types in that namespace must have been supplied by that module.

      Note that the old (non-module-typenamespace-specified) qmldir format still needs to be allowed, for QtQuick 1.x backward compatibility; a warning should be emitted the first time a particular legacy qmldir is imported. The types provided by such a qmldir are not protected within its namespace and may be overwritten etc by other modules.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mvogt Matthew Vogt (closed Nokia identity) (Inactive)
            chriadam Christopher Adams (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes