[hackers] [surf][PATCH] Add option for local file access from file:// URLs

From: Constantine Bytensky <kostya3_AT_gmail.com>
Date: Thu, 18 May 2017 14:46:49 +0300

I use it to open local .xml files with .xsl style-sheets.

---
 config.def.h | 1 +
 surf.c       | 7 +++++++
 2 files changed, 8 insertions(+)
diff --git a/config.def.h b/config.def.h
index 50dd739..ff6e7a4 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -10,6 +10,7 @@ static char *cookiefile     = "~/.surf/cookies.txt";
 /* Webkit default features */
 static Parameter defconfig[ParameterLast] = {
  SETB(AcceleratedCanvas,  1),
+ SETB(AccessFromFileURL,  0),
  SETB(Certificate,        0),
  SETB(CaretBrowsing,      0),
  SETV(CookiePolicies,     "_AT_Aa"),
diff --git a/surf.c b/surf.c
index 2d3a6f5..c811001 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -61,6 +61,7 @@ enum {
 typedef enum {
  AcceleratedCanvas,
+ AccessFromFileURL,
  CaretBrowsing,
  Certificate,
  CookiePolicies,
_AT_@ -678,6 +679,10 @@ setparameter(Client *c, int refresh, ParamName p,
const Arg *a)
  case AcceleratedCanvas:
  webkit_settings_set_enable_accelerated_2d_canvas(s, a->b);
  break;
+ case AccessFromFileURL:
+ webkit_settings_set_allow_file_access_from_file_urls(s, a->b);
+ webkit_settings_set_allow_universal_access_from_file_urls(s, a->b);
+ return; /* do not update */
  case CaretBrowsing:
  webkit_settings_set_enable_caret_browsing(s, a->b);
  refresh = 0;
_AT_@ -1020,6 +1025,8 @@ newview(Client *c, WebKitWebView *rv)
     webkit_web_view_new_with_related_view(rv));
  } else {
  settings = webkit_settings_new_with_settings(
+   "allow-file-access-from-file-urls", curconfig[AccessFromFileURL].val.b,
+   "allow-universal-access-from-file-urls", curconfig[AccessFromFileURL].val.b,
    "auto-load-images", curconfig[LoadImages].val.b,
    "default-charset", curconfig[DefaultCharset].val.v,
    "default-font-size", curconfig[FontSize].val.i,
--
2.13.0
Received on Thu May 18 2017 - 13:46:49 CEST

This archive was generated by hypermail 2.3.0 : Thu May 18 2017 - 13:48:17 CEST