Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Not Allowed load local resources QtWebEngine disable web security
Forum Updated to NodeBB v4.3 + New Features

Not Allowed load local resources QtWebEngine disable web security

Scheduled Pinned Locked Moved Unsolved QtWebEngine
4 Posts 2 Posters 4.4k 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.
  • G Offline
    G Offline
    GGAllin
    wrote on 17 Jun 2017, 14:48 last edited by
    #1

    Hi!

    I'm in trouble with WebEngine web security (on windows) and Qt 5.6.2

    Calling this method with runJavascript

    function doCreateVideoPage(sourcePath,config,start,finish,videofile)
    {
        document.getElementById("main-box").innerHTML = "";
    	var flashvars = "subtitles="+config+"&videourl="+sourcePath+"&start="+start+"&finish="+finish;
        var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="10%%" height="100%" id="webenginemanager" align="middle">'
        html += '<param name="movie" value="'+videofile+'" />'
        html += '<param name="FlashVars" value='+flashvars+' />'
        html += '<param name="quality" value="high" />'
        html += '<param  name="bgcolor" value="#000" />'
        html += '<param name="play" value="true" />'
        html += '<param name="loop" value="true" />'
        html += '<param name="wmode" value="window" />'
        html += '<param name="menu" value="true" />'
        html += '<param name="devicefont" value="false" />'
        html += '<param name="salign" value="" />'
        html += '<param name="allowScriptAccess" value="always" />'
        html += '<embed play="false" swliveconnect="true" name="webenginemanager" src="'+videofile+'?'+flashvars+'" quality="high" bgcolor="#000" width="100%" height="100%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"/>'
        html += '</object>'
        document.getElementById("main-box").innerHTML = html;
    }
    

    my VideoPlayer create correctly

    but get this error in console

     Not allowed to load local resource: file:///C:/Program%20Files%20(x86)/myapp/videoswf/videoplayer.swf?subtitles=C:/Users/dev/AppData/Local/myapp/bWVsb25pQGR1ZGF0Lml0/9788808436566/0b22b9e0-085a-406c-a0d0-f4a85867800e/yefe2e/bbbag/h1ay629z/gxan-nh0j9&videourl=C:/Users/dev/AppData/Local/myapp/bWVsb25pQGR1ZGF0Lml0/9788808436566/0b22b9e0-085a-406c-a0d0-f4a85867800e/yefe2e/bbbag/h1a62/gxanbnh0-q&start=&finish=
    

    So i've tried to run my QApplication with --disable-web-security

    int main(int argc, char *argv[])
    {
       // --ppapi-flash-path =/Users/mariomeloni/Develop/build/
    
        QCommandLineParser opts;
        argv[0] = "--disable-web-security"; // same error with argv[0]="disable-web-security"
        if(argc == 0)
            argc = 1;
        QApplication app(argc,argv);
        // more code
       app.exec();
    }
    

    I'm using Window with Qt 5.6.2

    Any suggestion are welcome
    Sorry for my bad english and thanks in advanced
    I'm really desparate
    GG

    1 Reply Last reply
    0
    • T Offline
      T Offline
      ThatDud3
      wrote on 19 Jun 2017, 15:39 last edited by ThatDud3
      #2

      WebEngine uses neither QCoreApplication::arguments() nor argc/argv
      On Windows they actually use GetCommandLineW

      https://bugreports.qt.io/browse/QTBUG-51963
      This approach does not seems to work, as those arguments are not used on Windows. All places calls GetCommandLine Windows API function.

      for quick test(ing) just try it from command line (or set it as run parameter in the IDE) e.g.:

      • from Qt X.X yy-bit for Desktop (MSVC ZZZZ) command prompt - run:
        myapp.exe --disable-web-security

      • or from IDE > Projects (wrench icon) > Build & Run (section) > Run > Command line arguments : <add> --disable-web-security

      A proper way to change main function arguments argc and argv in code:
      http://stackoverflow.com/questions/1519885/defining-own-main-functions-arguments-argc-and-argv
      (for a complete and C standard conforming solution see D.Shawley's answer)

      NB! argv[0] = /path/program.exe, argv[argc] = NULL
      NB! The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object.
      Note: argc and argv might be changed as Qt removes command line arguments that it recognizes.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GGAllin
        wrote on 20 Jun 2017, 09:36 last edited by
        #3

        Hi!
        Thanks for reply
        I "solved" my problem passing localhost://5052/C/Files [...] file path as arguments
        But still do not work.
        When the player are trying to load the video url a shell opens and close with a message that i can't read.
        I'm out of ideas

        1 Reply Last reply
        0
        • T Offline
          T Offline
          ThatDud3
          wrote on 20 Jun 2017, 15:09 last edited by ThatDud3
          #4

          localhost://.... is the same as 127.0.0.1://.... i.e. it will require (simple) web server to serve the content - I personally prefer latest Mongoose binary
          https://github.com/cesanta/mongoose

          Remember - file:///... protocol means the web browser should load the local file itself, while (local)host:port//... means your browser will try to load it from the server running on the designated host (even when it is local host)

          so now you have two options:

          • you could try '--disable-web-security' with file:///...
          • or try it with localhost://... with a running web-server on localhost (or 127.0.0.1) serving files from these folders
          1 Reply Last reply
          0

          1/4

          17 Jun 2017, 14:48

          • 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