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. Qt script engine problems
Forum Updated to NodeBB v4.3 + New Features

Qt script engine problems

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.0k 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.
  • P Offline
    P Offline
    Pt_develop
    wrote on last edited by
    #1

    I ran across a problem ("described here":http://qt-project.org/forums/viewthread/30161/) that seems to indicate some anomalous behavior in the Qt script engine as implemented in QtWebKit. I don't know how universal this "problem" is but my understanding is that the QtWebKit script engine is the same as the regular Qt script engine so I'm posting the problem here in the hopes of getting some help. The problem can be illustrated using the follow html:

    @<!DOCTYPE html5>
    <html>
    <head>
    <title>Alert test</title>
    [removed]
    window.onload=function(){
    var tst="x&";
    alert("tst0="+tst);
    tst="<x&";
    alert("tst1="+tst);
    tst="<x&";
    alert("tst2=\n"+tst);
    tst="\n<&";
    alert("tst3="+tst);
    }
    [removed]
    </head>
    <body>
    </body>
    </html>@

    (note; the code block has inserted an extra backslash in tst3 which is not present in the actual code and replaced script tags by [removed])

    All of these alert boxes should just contain the strings defined in tst. That is, the four alert boxes should display:

    first alert box display:
    tst0=x&

    second alert box display:
    tst1=<x&

    third alert box display:
    tst2=
    <x&

    fourth alert box display:
    tst3=
    <&

    All the major browsers (IE,FF,CHROME,SAFARI) produce these results but the Qt script engine produces the anomalous results:
    first alert box display:
    tst0=x&amp;

    second alert box display:
    tst1=<x&

    third alert box display:
    tst2=
    &lt;x&amp;

    fourth alert box display:
    tst3=
    &lt;&amp;

    Only tst1 results are identical to the results produced by the major browsers. It appears that somehow the text string is parsed by the alert method but I haven't been able to figure out the parsing algorithm . As can be seen from these results preceding a string of characters with a newline seems to cause characters for greater than (>), less than (<) and ampersand (&) to be replaced by their entity representations. Unfortunately it seems to be somewhat more complicated than this as can be seen from the txt0 and txt1 results.

    If anyone know the algorithm used by the script engine or knows how to prevent the alert method from inserting entities please let me know as, for me, this is a showstopper.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pt_develop
      wrote on last edited by
      #2

      In case others may run into this problem I managed to find a reliable work around by wrapping a QMessageBox in a QObject as a Q_INVOKABLE alert function and then connecting the object to a script.

      1 Reply Last reply
      0

      • Login

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