javascriptcwebkitwebkitgtk

webkitgtk custom scheme and XMLHttpRequest


I have a custom scheme ("embed") which serves data from an sqlite db

while I can do (inside a embed scheme page)

<img src="embed://any/old/uri/image.gif" />

if I try to do XMLHttpRequests I can only do relative paths, and only ones without double dots which seem to be stripped

Is there any way to get resources anywhere from the same scheme without issues. I notice the issue (as well as simple jscript tests) with three.js and howl.js It would be nice to be able to pull resources from anywhere within the same scheme.

I have tried the following

WebKitSettings *wks = webkit_web_view_get_settings (webView);
webkit_settings_set_enable_webgl (wks, TRUE);
webkit_settings_set_enable_webaudio (wks, TRUE);
webkit_settings_set_enable_xss_auditor(wks,FALSE);
webkit_settings_set_enable_hyperlink_auditing(wks, FALSE);
webkit_settings_set_enable_write_console_messages_to_stdout(wks, TRUE);

I also tried

webkit_security_manager_register_uri_scheme_as_local(wksm ,"embed");

but that seems to make things worse! I tried a bunch of other stuff but just seem to be chasing my own tail at the moment!

To be clear I'd be quite happy to turn off all "security" and let any embed:// resource have access to any other embed:// resource regardless of access method.


Solution

  • interesting one this!

    a URI specification must contain a domain

    as such this is the first part of the URI

    embed://demo/content/main.js
    embed://demo/image/texture.jpg
    

    will work (here main.js is accessing texture.jpg)

    embed://content/main.js
    embed://image/texture.jpg
    

    won't work! accessing texture.jpg from main.js looks to webkit as if a script on the content domain is accessing a resource on the image domain