On 20 January 2015 09:56, quoth Peter Bittner: > Now it looks like WebKit is rendering images from remote resources (e.g. > http://farm3.static.flickr.com/2256/2259897373_d47ecf0983_o_d.png) > fine, but local images (e.g. docs/reStPlugin.png) just display as an empty > box. Interestingly, the size of the box corresponds to the real size of the > image, but the image itself is not displayed. > > The box around the image is displayed only when the file exists, otherwise > only the ALT-text is visible. Looks like WebKit reads the image dimensions > out of the image file. I've tried setting a <base href="file://..."> tag in > the HTML head section, but that makes things worse ("** Message: console > message: @318: Not allowed to load local > resource: file:///home/.../doc/reStPlugin.png") > > Some details and a screenshot are available from a bug report at > https://github.com/bittner/gedit-reST-plugin/issues/7 > Carlos from the webkit-dev mailing list suggested "passing the right base URL > to the load method" may be missing > (https://lists.webkit.org/pipermail/webkit-dev/2015-January/027156.html).
It's a standard security feature of modern browsers to block all access to file:// URIs from pages loaded from anything other than a file:// URI. So if you want to render the content, you have to let the browser know that it's loading a local file. If you're passing the file:// URI to webkit_web_view_load_uri, this should be automatic. If you're using webkit_web_view_load_string, you need to specify an appropriate file:// URI as the base in the final parameter. (This does not need to actually exist as a file, but it will be used as the base for relative links.) It's not sufficient to use <base href> in the HTML content itself, as this is inherently untrustworthy for this purpose -- imagine if an HTML file on the public internet specified this, and then started trying to load your local files. You *might* also need to set the "enable-file-access-from-file-uris" property to true on webkit_web_settings as well, but I'm not sure exactly what this affects. Try it without that first. _______________________________________________ webkit-gtk mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-gtk
