Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set the default XmlReader or SvgReader in a Qt application
Forum Updated to NodeBB v4.3 + New Features

How to set the default XmlReader or SvgReader in a Qt application

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cyril1729
    wrote on 22 Jan 2014, 09:20 last edited by
    #1

    Hi!

    My Application displays html text in all sorts of widgets. I would like to be able to disable some of the features
    that come up with HTML, including svg and xml, to protect against e.g. lol bombs.

    My questions:

    • how can I get/modify the default XmlReader that Qt uses for parsing xml ? I want to set a entityResolver that does nothing, by doing something like:

      QApplication::getDefaultXmlReader()->setEntityResolver(NULL);

    .. but there's no such method as getDefaultXmlReader()

    • how can I disable svg at compilation time ? Apparently setting QT_NO_SVG has no effect except if recompilign Qt.

    Thanks a lot for your help!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 22 Jan 2014, 10:38 last edited by
      #2

      Hi,

      How are you currently parsing XML documents? There is no "default XML reader". You need to explicitly instantiate a "QXmlStreamReader":http://qt-project.org/doc/qt-5/QXmlStreamReader.html, or explicitly use the classes from the older "Qt XML module":http://qt-project.org/doc/qt-5/qtxml-module.html.

      SVG support is provided through a separate "Qt SVG module":http://qt-project.org/doc/qt-5/qtsvg-index.html. Simply omit the module from your project, and don't deploy the SVG-related shared libraries with your app. Your app won't read SVG files then.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cyril1729
        wrote on 22 Jan 2014, 12:25 last edited by
        #3

        Thanks for the reply.

        I'm parsing XML documents implicitly when I do:

        myRTextBrowser->setHtml( string_in_html ) ;
        

        or

        myLabel->setText( string_in_html ) ;

        when doing that, Qt parses the html in the string and interprets all content, includign embedded images, some of which are SVG => calls a Xml parser.

        So there must be somewhere in Qt, a default XmlParser object on which I can call setDefaultEntityResolver(NULL).

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JKSH
          Moderators
          wrote on 25 Jan 2014, 05:15 last edited by
          #4

          QTextBrowser and QLabel use a rich text engine which supports a subset of HTML and CSS, but doesn't understand XML entities (see http://qt-project.org/doc/qt-5/richtext-html-subset.html ). Unrecognized tags are simply ignored; any textual content within the unrecognized tags are displayed as plain text.

          Inputting a HTML document with embedded SVG (e.g. http://www.w3schools.com/svg/svg_inhtml.asp ) displays the text, but not the image.

          Inputting a lol bomb is harmless, as it won't get expanded.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0

          1/4

          22 Jan 2014, 09:20

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved