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

QString::toHtmlEscaped() does not handle the ">" symbol correctly when there is no "<" preceding it

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.0.1
    • None

    Description

      to escape Html tags, "<" is replaced with "& lt;" and ">" is replaced with "& gt;".
      However, when there is no "<" preceding a ">", the ">" should NOT be replaced by " & gt;".

      "<b>" will be correctly converted to "& lt;b& gt;"
      ">test" will be INCORRECTLY converted to "& gt;test" as html will display it as "& gt;test" instead of ">test"

      currently, i circumvent this problem by doing the following:

      QString line;
      ...
      if(line.indexOf("<",0)<line.indexOf(">",0))
      {
       line.replace("<","& lt;");
      }
      else
      {
       line.replace("<","& lt;");line.replace(">","& gt;");
      }
      

      also, i had to type a space in between the "&" and "gt;" for this bugreport, because otherwise they would be displayed incorrectly.

      Attachments

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

        Activity

          People

            biochimia João Abecasis
            martijnvdc Martijn Vandecasteele
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes