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

QTextDocumentFragment does not work expectedly.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2, 6.2.3, 6.2.4, 6.3.0
    • None

    Description

      if the html contains stylesheet or script .
      QTextDocumentFragment::fromHtml can not work .

      the expected `size >0`

          QString t="<div class=\"mdict\"><link rel=\"stylesheet\" href=\"a.css\"><h2><a>advice</a>:建议</h2><p>同advise.与advise的区别主要是后期语言学者人为的影响</p></div>";
          int size = QTextDocumentFragment::fromHtml( t ).toPlainText().length();
      

      expected size>0
      actual result : size=0;

      the following html contain script node .
      QTextDocumentFragment::fromHtml( t ).toPlainText() does not work neither.

          QString t="<div class=\"mdict\"><head><script src=\"a.js\" charset=\"utf-8\" type=\"text/javascript\" language=\"javascript\"></script></head>test</div>";
      

      remove stylesheet .the html can work normally.

          QString t="<div class=\"mdict\"><h2><a>advice</a>:建议</h2><p>同advise.与advise的区别主要是后期语言学者人为的影响</p></div>";
      

      see attachment.

      another issue:
      if the html is

          QString t="<div><z>down</z><z>load</z></div>";
          auto size = QTextDocumentFragment::fromHtml( t ).toPlainText();
      

      the expected result is : down load
      the actual result is : download

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            xiaoyifang yifang xiao
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes