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

Weird behavior when pasting certain HTML into element with contentEditable attribute set

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.2.3, 6.3.0 Alpha
    • 5.9.9, 5.12.10, 5.15.2, 6.2.1
    • WebEngine
    • None
    • Windows
    • 74021bfcb8f3937e960e76c39d06f5a2a6304673 (qt/qtwebengine/dev) 5a2db0883cc6acadebf3fa0197c36d81af167492 (qt/qtwebengine/6.2)

    Description

      I have encountered an annoying issue where if user wants to insert certain HTML (which we assume he copied from somewhere else) into the HTML element that has contentEditable attribute set to true, it results in some weird behavior.

      It boils down to:

      1. User have copied some "weird" HTML.
      2. contentEditable element has some text in it.
      3. User pastes HTML before text in the element.
      4. Caret is moved in unexpected way:
        1. Upon reaching 2 pastes on the single line, cursor will be moved to a new line. This happens up until we hit existing text. Attempting to paste on the line with existing text will:
          1. Crash WebEngine process (5.9.9, debug)
          2. Remove existing text and get "stuck" (meaning, nothing happens on subsequent attempts to paste text) in insert loop. (5.9.9, release).
        2. Caret is moved to next line after every paste up until reaching line with existing text. Attempting to paste here will result in HTML being inserted after existing text. Subsequent pastes are producing expected behavior. (5.12.10, debug/release).
        3. Similar behavior as in 1st case, but after reaching text it will behave like in 2nd. (5.15.2, debug/release)

       

      Steps to reproduce: 

      1. Compile attached example with Qt 5.9.9, 5.12.10 or 5.15.2 using MSVC 2017. 
      2. Go to this MDN page on outline style.
      3. Select and copy string <'outline-color'> under Values section.
      4. Start an app, place caret on the top of contentEditable element.
      5. Press CTRL + V until you see a result.

       

      If description is too difficult to understand at first, let me know so I can record a video. 

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-92539
          # Subject Branch Project Status CR V

          Activity

            People

              pvarga Peter Varga
              kef Egor Krugletsov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes