[webkit-gtk] WebKit not rendering images of a local resource (from within Gedit)

Peter Bittner peter.bittner at gmx.net
Tue Jan 20 03:54:27 PST 2015


Awesome, Gavin, thank you!

Setting the last parameter of the load_string() method works.
http://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitwebview.html#webkit-web-view-load-string

Now I just need to supply the actual file path - if that content is
already saved as a file, apparently, or Gedit's "working directory"
for unsaved files, as a default.

Any hints on where I can find that information? (Are there any API
docs of Gedit anywhere?)

Thanks so much,
Peter



2015-01-19 22:45 GMT+01:00 Gavin Lambert <gavinl at compacsort.com>:
> 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.
>
>


More information about the webkit-gtk mailing list