.gitignore                       |    3 
 Makefile.am                      |    2 
 autogen.sh                       |    2 
 configure.ac                     |   11 -
 loleaflet/.eslintignore          |    1 
 loleaflet/Makefile.am            |  176 ++-------------------
 loleaflet/html/loleaflet.html.m4 |   78 +++++----
 loleaflet/js/global.js           |   32 ---
 loleaflet/src/errormessages.js   |    7 
 m4/ax_boost_base.m4              |  266 ---------------------------------
 m4/ax_boost_locale.m4            |  122 ---------------
 wsd/FileServer.cpp               |  313 ++-------------------------------------
 wsd/FileServer.hpp               |    3 
 wsd/LOOLWSD.cpp                  |    7 
 wsd/LOOLWSD.hpp                  |    2 
 15 files changed, 103 insertions(+), 922 deletions(-)

New commits:
commit e5ecc9265923a9ede6a85e944b919243130261a3
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:46:58 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "loleaflet: execute l10n.js script after html parsing"
    
    This reverts commit e512924544b44421bb2cb5eb563f7c40249daf8c.
    
    Change-Id: I9b322b45cd13b69c4438d48227237dd8062aee05

diff --git a/loleaflet/.eslintignore b/loleaflet/.eslintignore
index e4fc0c88d..6f11545b6 100644
--- a/loleaflet/.eslintignore
+++ b/loleaflet/.eslintignore
@@ -5,4 +5,3 @@
 #
 # This is way too ugly for eslint...
 **/js/jquery.mCustomScrollbar.js
-**/js/l10n.js
diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index 5be8db596..9cf916e57 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -175,7 +175,6 @@ $(builddir)/dist/bundle.js: $(NODE_MODULES_JS_DST) \
        $(LOLEAFLET_PREFIX)/dist/loleaflet-src.js \
        $(builddir)/dist/global.js \
        $(builddir)/dist/jquery.mCustomScrollbar.js \
-       $(builddir)/dist/l10n.js \
        $(builddir)/dist/w2ui-1.5.rc1.js
        @touch $@
 else
@@ -201,7 +200,6 @@ $(builddir)/dist/global.js: $(srcdir)/js/global.js
 $(builddir)/dist/bundle.js: $(NODE_MODULES_JS_SRC) \
        $(LOLEAFLET_PREFIX)/dist/loleaflet-src.js \
        $(builddir)/dist/global.js \
-       $(builddir)/dist/l10n.js \
        $(srcdir)/js/jquery.mCustomScrollbar.js \
        $(srcdir)/js/w2ui-1.5.rc1.js
        @echo "Uglify loleaflet js files..."
@@ -226,7 +224,6 @@ $(builddir)/dist/loleaflet.html: 
$(srcdir)/html/loleaflet.html.m4 $(LOLEAFLET_HT
                -DLOLEAFLET_CSS="$(subst 
$(SPACE),$(COMMA),$(LOLEAFLET_CSS_M4))" \
                -DBUNDLE_CSS="$(abs_builddir)/dist/bundle.css" \
                -DGLOBAL_JS="$(abs_builddir)/dist/global.js" \
-               -DL10N_JS="$(abs_builddir)/dist/l10n.js" \
                -DLOLEAFLET_JS="$(subst $(SPACE),$(COMMA),$(NODE_MODULES_JS) \
                jquery.mCustomScrollbar.js \
                w2ui-1.5.rc1.js \
diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index bdfa49e5c..272464a66 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -170,7 +170,6 @@ ifelse(MOBILEAPP,[true],
       window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;
       window.tileSize = 256;])
 syscmd([cat ]GLOBAL_JS)dnl
-syscmd([cat ]L10N_JS)dnl
     </script>
   <script defer>
 
diff --git a/loleaflet/js/l10n.js b/loleaflet/js/l10n.js
deleted file mode 100644
index 4beab6e7a..000000000
--- a/loleaflet/js/l10n.js
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * l10n.js
- * 2016-05-17
- * 
- * By Eli Grey, http://eligrey.com
- * Licensed under the MIT License
- *   See https://github.com/eligrey/l10n.js/blob/master/LICENSE.md
- */
-
-/*global XMLHttpRequest, setTimeout, document, navigator, ActiveXObject*/
-
-/*! @source http://purl.eligrey.com/github/l10n.js/blob/master/l10n.js*/
-
-(function () {
-"use strict";
-
-var
-  undef_type = "undefined"
-, string_type = "string"
-, nav = {}
-, String_ctr = String
-, has_own_prop = Object.prototype.hasOwnProperty
-, load_queues = {}
-, localizations = {}
-, FALSE = !1
-, TRUE = !0
-, browserless = FALSE
-// the official format is application/vnd.oftn.l10n+json, though l10n.js will 
also
-// accept application/x-l10n+json and application/l10n+json
-, l10n_js_media_type = 
/^\s*application\/(?:vnd\.oftn\.|x-)?l10n\+json\s*(?:$|;)/i
-, XHR
-
-// property minification aids
-, $locale = "locale"
-, $default_locale = "defaultLocale"
-, $to_locale_string = "toLocaleString"
-, $to_lowercase = "toLowerCase"
-
-, array_index_of = Array.prototype.indexOf || function (item) {
-       var
-         len = this.length
-       , i   = 0
-       ;
-       
-       for (; i < len; i++) {
-               if (i in this && this[i] === item) {
-                       return i;
-               }
-       }
-       
-       return -1;
-}
-, request_JSON = function (uri) {
-    if(browserless)
-        return loadFromDisk(uri);
-    
-       var req  = new XHR(),
-               data = {};
-       
-       // sadly, this has to be blocking to allow for a graceful degrading API
-       req.open("GET", uri, FALSE);
-       req.send(null);
-       
-       // Status codes can be inconsistent across browsers so we simply try to 
parse
-       // the response text and catch any errors. This deals with failed 
requests as
-       // well as malformed json files.
-       try {
-               data = JSON.parse(req.responseText);
-       } catch(e) {
-               // warn about error without stopping execution
-               setTimeout(function () {
-                       // Error messages are not localized as not to cause an 
infinite loop
-                       var l10n_err = new Error("Unable to load localization 
data: " + uri);
-                       l10n_err.name = "Localization Error";
-                       throw l10n_err;
-               }, 0);
-       }
-
-       return data;
-}
-, load = String_ctr[$to_locale_string] = function (data) {
-       // don't handle function.toLocaleString(indentationAmount:Number)
-       if (arguments.length > 0 && typeof data !== "number") {
-               if (typeof data === string_type) {
-                       load(request_JSON(data));
-               } else if (data === FALSE) {
-                       // reset all localizations
-                       localizations = {};
-               } else {
-                       // Extend current localizations instead of completely 
overwriting them
-                       var locale, localization, message;
-                       for (locale in data) {
-                               if (has_own_prop.call(data, locale)) {
-                                       localization = data[locale];
-                                       locale = locale[$to_lowercase]();
-                                       
-                                       if (!(locale in localizations) || 
localization === FALSE) {
-                                               // reset locale if not existing 
or reset flag is specified
-                                               localizations[locale] = {};
-                                       }
-                                       
-                                       if (localization === FALSE) {
-                                               continue;
-                                       }
-                                       
-                                       // URL specified
-                                       if (typeof localization === 
string_type) {
-                                               if 
(String_ctr[$locale][$to_lowercase]().indexOf(locale) === 0) {
-                                                       localization = 
request_JSON(localization);
-                                               } else {
-                                                       // queue loading locale 
if not needed
-                                                       if (!(locale in 
load_queues)) {
-                                                               
load_queues[locale] = [];
-                                                       }
-                                                       
load_queues[locale].push(localization);
-                                                       continue;
-                                               }
-                                       }
-                                       
-                                       for (message in localization) {
-                                               if 
(has_own_prop.call(localization, message)) {
-                                                       
localizations[locale][message] = localization[message];
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-       // Return what function.toLocaleString() normally returns
-       return Function.prototype[$to_locale_string].apply(String_ctr, 
arguments);
-}
-, loadFromDisk = String_ctr[$to_locale_string] = function (uri) {
-        const fs = require('fs');
-        var read = fs.readFileSync(uri, 'utf8');
-        return JSON.parse(read);
-}
-, process_load_queue = function (locale) {
-       var
-         queue = load_queues[locale]
-       , i = 0
-       , len = queue.length
-       , localization
-       ;
-       
-       for (; i < len; i++) {
-               localization = {};
-               localization[locale] = request_JSON(queue[i]);
-               load(localization);
-       }
-       
-       delete load_queues[locale];
-}
-, use_default
-, localize = String_ctr.prototype[$to_locale_string] = function () {
-       var
-         using_default = use_default
-       , current_locale = String_ctr[using_default ? $default_locale : $locale]
-       , parts = current_locale[$to_lowercase]().split("-")
-       , i = parts.length
-       , this_val = this.valueOf()
-       , locale
-       ;
-
-       use_default = FALSE;
-       
-       // Iterate through locales starting at most-specific until a 
localization is found
-       do {
-               locale = parts.slice(0, i).join("-");
-               // load locale if not loaded
-               if (locale in load_queues) {
-                       process_load_queue(locale);
-               }
-               if (locale in localizations && this_val in 
localizations[locale]) {
-                       return localizations[locale][this_val];
-               }
-       }
-       while (i--);
-       
-       if (!using_default && String_ctr[$default_locale]) {
-               use_default = TRUE;
-               return localize.call(this_val);
-       }
-
-       return this_val;
-}
-;
-
-try 
-{
-    nav = self.navigator;
-}
-catch(selfNotFoundException)
-{
-   if(global.nav)
-   {
-        nav = global.nav;
-   }
-   else
-   {
-       var nodeError = "Problem setting nav in L10N. You are most likely 
running in a non-browser environment like Node." + 
-        "If this is the case, you can resolve this error by setting global.nav 
to an object which contains a \"language\"  field. ";
-       throw new Error(nodeError);
-   }
-   browserless = TRUE;
-}
-
-if (!browserless && typeof XMLHttpRequest === undef_type && typeof 
ActiveXObject !== undef_type) {
-       var AXO = ActiveXObject;
-       
-       XHR = function () {
-               try {
-                       return new AXO("Msxml2.XMLHTTP.6.0");
-               } catch (xhrEx1) {}
-               try {
-                       return new AXO("Msxml2.XMLHTTP.3.0");
-               } catch (xhrEx2) {}
-               try {
-                       return new AXO("Msxml2.XMLHTTP");
-               } catch (xhrEx3) {}
-       
-               throw new Error("XMLHttpRequest not supported by this 
browser.");
-       };
-} else {
-    try
-    {
-        XHR = XMLHttpRequest;
-    }
-    catch(xhrEx4)
-    {   
-        if(global.XMLHttpRequest) {
-            XHR = global.XMLHttpRequest;
-        }
-        else {
-           var nodeError = "Problem setting XHR in L10N. You are most likely 
running in a non-browser environment like Node." + 
-            "If this is the case, you can resolve this error by setting 
global.XMLHttpRequest to a function which produces XMLHttpRequests. " + 
-            "\nTip: if you are using node, you might want to use the XHR2 
package (usage: global.XMLHttpRequest = require('xhr2')";
-            throw new Error(nodeError); 
-        }
-    }
-}
-
-String_ctr[$default_locale] = String_ctr[$default_locale] || "";
-String_ctr[$locale] = nav && (nav.language || nav.userLanguage) || "";
-
-if (!browserless || typeof document !== undef_type) {
-       var
-         elts = document.getElementsByTagName("link")
-       , i = elts.length
-       , localization
-       ;
-       
-       while (i--) {
-               var
-                 elt = elts[i]
-               , rel = (elt.getAttribute("rel") || 
"")[$to_lowercase]().split(/\s+/)
-               ;
-               
-               if (l10n_js_media_type.test(elt.type)) {
-                       if (array_index_of.call(rel, "localizations") !== -1) {
-                               // multiple localizations
-                               load(elt.getAttribute("href"));
-                       } else if (array_index_of.call(rel, "localization") !== 
-1) {
-                               // single localization
-                               localization = {};
-                               localization[(elt.getAttribute("hreflang") || 
"")[$to_lowercase]()] =
-                                       elt.getAttribute("href");
-                               load(localization);
-                       }
-               }
-       }
-}
-else
-{
-    if(global.l10NLocalFilePath) {
-        load(global.l10NLocalFilePath);
-    }
-    else {
-        var nodeError = "Problem loading localization file. You are most 
likely running in a non-browser environment like Node." + 
-            "If this is the case, you can resolve this error by setting 
global.l10NLocalFilePath to the path of your localization file. ";
-        throw new Error(nodeError); 
-    }
-}
-
-}());
commit cbc85953e8232e9f710a525313b674d62dbff18e
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:46:08 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "loleaflet: set format unix l10n.js"
    
    This reverts commit ab2051cd50dc4b1bb6e579fbad15afea5a9cedf1.

diff --git a/loleaflet/js/l10n.js b/loleaflet/js/l10n.js
index 0057eed74..4beab6e7a 100644
--- a/loleaflet/js/l10n.js
+++ b/loleaflet/js/l10n.js
@@ -1,284 +1,284 @@
-/*
- * l10n.js
- * 2016-05-17
- *
- * By Eli Grey, http://eligrey.com
- * Licensed under the MIT License
- *   See https://github.com/eligrey/l10n.js/blob/master/LICENSE.md
- */
-
-/*global XMLHttpRequest, setTimeout, document, navigator, ActiveXObject*/
-
-/*! @source http://purl.eligrey.com/github/l10n.js/blob/master/l10n.js*/
-
-(function () {
-"use strict";
-
-var
-  undef_type = "undefined"
-, string_type = "string"
-, nav = {}
-, String_ctr = String
-, has_own_prop = Object.prototype.hasOwnProperty
-, load_queues = {}
-, localizations = {}
-, FALSE = !1
-, TRUE = !0
-, browserless = FALSE
-// the official format is application/vnd.oftn.l10n+json, though l10n.js will 
also
-// accept application/x-l10n+json and application/l10n+json
-, l10n_js_media_type = 
/^\s*application\/(?:vnd\.oftn\.|x-)?l10n\+json\s*(?:$|;)/i
-, XHR
-
-// property minification aids
-, $locale = "locale"
-, $default_locale = "defaultLocale"
-, $to_locale_string = "toLocaleString"
-, $to_lowercase = "toLowerCase"
-
-, array_index_of = Array.prototype.indexOf || function (item) {
-       var
-         len = this.length
-       , i   = 0
-       ;
-
-       for (; i < len; i++) {
-               if (i in this && this[i] === item) {
-                       return i;
-               }
-       }
-
-       return -1;
-}
-, request_JSON = function (uri) {
-    if(browserless)
-        return loadFromDisk(uri);
-
-       var req  = new XHR(),
-               data = {};
-
-       // sadly, this has to be blocking to allow for a graceful degrading API
-       req.open("GET", uri, FALSE);
-       req.send(null);
-
-       // Status codes can be inconsistent across browsers so we simply try to 
parse
-       // the response text and catch any errors. This deals with failed 
requests as
-       // well as malformed json files.
-       try {
-               data = JSON.parse(req.responseText);
-       } catch(e) {
-               // warn about error without stopping execution
-               setTimeout(function () {
-                       // Error messages are not localized as not to cause an 
infinite loop
-                       var l10n_err = new Error("Unable to load localization 
data: " + uri);
-                       l10n_err.name = "Localization Error";
-                       throw l10n_err;
-               }, 0);
-       }
-
-       return data;
-}
-, load = String_ctr[$to_locale_string] = function (data) {
-       // don't handle function.toLocaleString(indentationAmount:Number)
-       if (arguments.length > 0 && typeof data !== "number") {
-               if (typeof data === string_type) {
-                       load(request_JSON(data));
-               } else if (data === FALSE) {
-                       // reset all localizations
-                       localizations = {};
-               } else {
-                       // Extend current localizations instead of completely 
overwriting them
-                       var locale, localization, message;
-                       for (locale in data) {
-                               if (has_own_prop.call(data, locale)) {
-                                       localization = data[locale];
-                                       locale = locale[$to_lowercase]();
-
-                                       if (!(locale in localizations) || 
localization === FALSE) {
-                                               // reset locale if not existing 
or reset flag is specified
-                                               localizations[locale] = {};
-                                       }
-
-                                       if (localization === FALSE) {
-                                               continue;
-                                       }
-
-                                       // URL specified
-                                       if (typeof localization === 
string_type) {
-                                               if 
(String_ctr[$locale][$to_lowercase]().indexOf(locale) === 0) {
-                                                       localization = 
request_JSON(localization);
-                                               } else {
-                                                       // queue loading locale 
if not needed
-                                                       if (!(locale in 
load_queues)) {
-                                                               
load_queues[locale] = [];
-                                                       }
-                                                       
load_queues[locale].push(localization);
-                                                       continue;
-                                               }
-                                       }
-
-                                       for (message in localization) {
-                                               if 
(has_own_prop.call(localization, message)) {
-                                                       
localizations[locale][message] = localization[message];
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-       // Return what function.toLocaleString() normally returns
-       return Function.prototype[$to_locale_string].apply(String_ctr, 
arguments);
-}
-, loadFromDisk = String_ctr[$to_locale_string] = function (uri) {
-        const fs = require('fs');
-        var read = fs.readFileSync(uri, 'utf8');
-        return JSON.parse(read);
-}
-, process_load_queue = function (locale) {
-       var
-         queue = load_queues[locale]
-       , i = 0
-       , len = queue.length
-       , localization
-       ;
-
-       for (; i < len; i++) {
-               localization = {};
-               localization[locale] = request_JSON(queue[i]);
-               load(localization);
-       }
-
-       delete load_queues[locale];
-}
-, use_default
-, localize = String_ctr.prototype[$to_locale_string] = function () {
-       var
-         using_default = use_default
-       , current_locale = String_ctr[using_default ? $default_locale : $locale]
-       , parts = current_locale[$to_lowercase]().split("-")
-       , i = parts.length
-       , this_val = this.valueOf()
-       , locale
-       ;
-
-       use_default = FALSE;
-
-       // Iterate through locales starting at most-specific until a 
localization is found
-       do {
-               locale = parts.slice(0, i).join("-");
-               // load locale if not loaded
-               if (locale in load_queues) {
-                       process_load_queue(locale);
-               }
-               if (locale in localizations && this_val in 
localizations[locale]) {
-                       return localizations[locale][this_val];
-               }
-       }
-       while (i--);
-
-       if (!using_default && String_ctr[$default_locale]) {
-               use_default = TRUE;
-               return localize.call(this_val);
-       }
-
-       return this_val;
-}
-;
-
-try
-{
-    nav = self.navigator;
-}
-catch(selfNotFoundException)
-{
-   if(global.nav)
-   {
-        nav = global.nav;
-   }
-   else
-   {
-       var nodeError = "Problem setting nav in L10N. You are most likely 
running in a non-browser environment like Node." +
-        "If this is the case, you can resolve this error by setting global.nav 
to an object which contains a \"language\"  field. ";
-       throw new Error(nodeError);
-   }
-   browserless = TRUE;
-}
-
-if (!browserless && typeof XMLHttpRequest === undef_type && typeof 
ActiveXObject !== undef_type) {
-       var AXO = ActiveXObject;
-
-       XHR = function () {
-               try {
-                       return new AXO("Msxml2.XMLHTTP.6.0");
-               } catch (xhrEx1) {}
-               try {
-                       return new AXO("Msxml2.XMLHTTP.3.0");
-               } catch (xhrEx2) {}
-               try {
-                       return new AXO("Msxml2.XMLHTTP");
-               } catch (xhrEx3) {}
-
-               throw new Error("XMLHttpRequest not supported by this 
browser.");
-       };
-} else {
-    try
-    {
-        XHR = XMLHttpRequest;
-    }
-    catch(xhrEx4)
-    {
-        if(global.XMLHttpRequest) {
-            XHR = global.XMLHttpRequest;
-        }
-        else {
-           var nodeError = "Problem setting XHR in L10N. You are most likely 
running in a non-browser environment like Node." +
-            "If this is the case, you can resolve this error by setting 
global.XMLHttpRequest to a function which produces XMLHttpRequests. " +
-            "\nTip: if you are using node, you might want to use the XHR2 
package (usage: global.XMLHttpRequest = require('xhr2')";
-            throw new Error(nodeError);
-        }
-    }
-}
-
-String_ctr[$default_locale] = String_ctr[$default_locale] || "";
-String_ctr[$locale] = nav && (nav.language || nav.userLanguage) || "";
-
-if (!browserless || typeof document !== undef_type) {
-       var
-         elts = document.getElementsByTagName("link")
-       , i = elts.length
-       , localization
-       ;
-
-       while (i--) {
-               var
-                 elt = elts[i]
-               , rel = (elt.getAttribute("rel") || 
"")[$to_lowercase]().split(/\s+/)
-               ;
-
-               if (l10n_js_media_type.test(elt.type)) {
-                       if (array_index_of.call(rel, "localizations") !== -1) {
-                               // multiple localizations
-                               load(elt.getAttribute("href"));
-                       } else if (array_index_of.call(rel, "localization") !== 
-1) {
-                               // single localization
-                               localization = {};
-                               localization[(elt.getAttribute("hreflang") || 
"")[$to_lowercase]()] =
-                                       elt.getAttribute("href");
-                               load(localization);
-                       }
-               }
-       }
-}
-else
-{
-    if(global.l10NLocalFilePath) {
-        load(global.l10NLocalFilePath);
-    }
-    else {
-        var nodeError = "Problem loading localization file. You are most 
likely running in a non-browser environment like Node." +
-            "If this is the case, you can resolve this error by setting 
global.l10NLocalFilePath to the path of your localization file. ";
-        throw new Error(nodeError);
-    }
-}
-
-}());
+/*
+ * l10n.js
+ * 2016-05-17
+ * 
+ * By Eli Grey, http://eligrey.com
+ * Licensed under the MIT License
+ *   See https://github.com/eligrey/l10n.js/blob/master/LICENSE.md
+ */
+
+/*global XMLHttpRequest, setTimeout, document, navigator, ActiveXObject*/
+
+/*! @source http://purl.eligrey.com/github/l10n.js/blob/master/l10n.js*/
+
+(function () {
+"use strict";
+
+var
+  undef_type = "undefined"
+, string_type = "string"
+, nav = {}
+, String_ctr = String
+, has_own_prop = Object.prototype.hasOwnProperty
+, load_queues = {}
+, localizations = {}
+, FALSE = !1
+, TRUE = !0
+, browserless = FALSE
+// the official format is application/vnd.oftn.l10n+json, though l10n.js will 
also
+// accept application/x-l10n+json and application/l10n+json
+, l10n_js_media_type = 
/^\s*application\/(?:vnd\.oftn\.|x-)?l10n\+json\s*(?:$|;)/i
+, XHR
+
+// property minification aids
+, $locale = "locale"
+, $default_locale = "defaultLocale"
+, $to_locale_string = "toLocaleString"
+, $to_lowercase = "toLowerCase"
+
+, array_index_of = Array.prototype.indexOf || function (item) {
+       var
+         len = this.length
+       , i   = 0
+       ;
+       
+       for (; i < len; i++) {
+               if (i in this && this[i] === item) {
+                       return i;
+               }
+       }
+       
+       return -1;
+}
+, request_JSON = function (uri) {
+    if(browserless)
+        return loadFromDisk(uri);
+    
+       var req  = new XHR(),
+               data = {};
+       
+       // sadly, this has to be blocking to allow for a graceful degrading API
+       req.open("GET", uri, FALSE);
+       req.send(null);
+       
+       // Status codes can be inconsistent across browsers so we simply try to 
parse
+       // the response text and catch any errors. This deals with failed 
requests as
+       // well as malformed json files.
+       try {
+               data = JSON.parse(req.responseText);
+       } catch(e) {
+               // warn about error without stopping execution
+               setTimeout(function () {
+                       // Error messages are not localized as not to cause an 
infinite loop
+                       var l10n_err = new Error("Unable to load localization 
data: " + uri);
+                       l10n_err.name = "Localization Error";
+                       throw l10n_err;
+               }, 0);
+       }
+
+       return data;
+}
+, load = String_ctr[$to_locale_string] = function (data) {
+       // don't handle function.toLocaleString(indentationAmount:Number)
+       if (arguments.length > 0 && typeof data !== "number") {
+               if (typeof data === string_type) {
+                       load(request_JSON(data));
+               } else if (data === FALSE) {
+                       // reset all localizations
+                       localizations = {};
+               } else {
+                       // Extend current localizations instead of completely 
overwriting them
+                       var locale, localization, message;
+                       for (locale in data) {
+                               if (has_own_prop.call(data, locale)) {
+                                       localization = data[locale];
+                                       locale = locale[$to_lowercase]();
+                                       
+                                       if (!(locale in localizations) || 
localization === FALSE) {
+                                               // reset locale if not existing 
or reset flag is specified
+                                               localizations[locale] = {};
+                                       }
+                                       
+                                       if (localization === FALSE) {
+                                               continue;
+                                       }
+                                       
+                                       // URL specified
+                                       if (typeof localization === 
string_type) {
+                                               if 
(String_ctr[$locale][$to_lowercase]().indexOf(locale) === 0) {
+                                                       localization = 
request_JSON(localization);
+                                               } else {
+                                                       // queue loading locale 
if not needed
+                                                       if (!(locale in 
load_queues)) {
+                                                               
load_queues[locale] = [];
+                                                       }
+                                                       
load_queues[locale].push(localization);
+                                                       continue;
+                                               }
+                                       }
+                                       
+                                       for (message in localization) {
+                                               if 
(has_own_prop.call(localization, message)) {
+                                                       
localizations[locale][message] = localization[message];
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       // Return what function.toLocaleString() normally returns
+       return Function.prototype[$to_locale_string].apply(String_ctr, 
arguments);
+}
+, loadFromDisk = String_ctr[$to_locale_string] = function (uri) {
+        const fs = require('fs');
+        var read = fs.readFileSync(uri, 'utf8');
+        return JSON.parse(read);
+}
+, process_load_queue = function (locale) {
+       var
+         queue = load_queues[locale]
+       , i = 0
+       , len = queue.length
+       , localization
+       ;
+       
+       for (; i < len; i++) {
+               localization = {};
+               localization[locale] = request_JSON(queue[i]);
+               load(localization);
+       }
+       
+       delete load_queues[locale];
+}
+, use_default
+, localize = String_ctr.prototype[$to_locale_string] = function () {
+       var
+         using_default = use_default
+       , current_locale = String_ctr[using_default ? $default_locale : $locale]
+       , parts = current_locale[$to_lowercase]().split("-")
+       , i = parts.length
+       , this_val = this.valueOf()
+       , locale
+       ;
+
+       use_default = FALSE;
+       
+       // Iterate through locales starting at most-specific until a 
localization is found
+       do {
+               locale = parts.slice(0, i).join("-");
+               // load locale if not loaded
+               if (locale in load_queues) {
+                       process_load_queue(locale);
+               }
+               if (locale in localizations && this_val in 
localizations[locale]) {
+                       return localizations[locale][this_val];
+               }
+       }
+       while (i--);
+       
+       if (!using_default && String_ctr[$default_locale]) {
+               use_default = TRUE;
+               return localize.call(this_val);
+       }
+
+       return this_val;
+}
+;
+
+try 
+{
+    nav = self.navigator;
+}
+catch(selfNotFoundException)
+{
+   if(global.nav)
+   {
+        nav = global.nav;
+   }
+   else
+   {
+       var nodeError = "Problem setting nav in L10N. You are most likely 
running in a non-browser environment like Node." + 
+        "If this is the case, you can resolve this error by setting global.nav 
to an object which contains a \"language\"  field. ";
+       throw new Error(nodeError);
+   }
+   browserless = TRUE;
+}
+
+if (!browserless && typeof XMLHttpRequest === undef_type && typeof 
ActiveXObject !== undef_type) {
+       var AXO = ActiveXObject;
+       
+       XHR = function () {
+               try {
+                       return new AXO("Msxml2.XMLHTTP.6.0");
+               } catch (xhrEx1) {}
+               try {
+                       return new AXO("Msxml2.XMLHTTP.3.0");
+               } catch (xhrEx2) {}
+               try {
+                       return new AXO("Msxml2.XMLHTTP");
+               } catch (xhrEx3) {}
+       
+               throw new Error("XMLHttpRequest not supported by this 
browser.");
+       };
+} else {
+    try
+    {
+        XHR = XMLHttpRequest;
+    }
+    catch(xhrEx4)
+    {   
+        if(global.XMLHttpRequest) {
+            XHR = global.XMLHttpRequest;
+        }
+        else {
+           var nodeError = "Problem setting XHR in L10N. You are most likely 
running in a non-browser environment like Node." + 
+            "If this is the case, you can resolve this error by setting 
global.XMLHttpRequest to a function which produces XMLHttpRequests. " + 
+            "\nTip: if you are using node, you might want to use the XHR2 
package (usage: global.XMLHttpRequest = require('xhr2')";
+            throw new Error(nodeError); 
+        }
+    }
+}
+
+String_ctr[$default_locale] = String_ctr[$default_locale] || "";
+String_ctr[$locale] = nav && (nav.language || nav.userLanguage) || "";
+
+if (!browserless || typeof document !== undef_type) {
+       var
+         elts = document.getElementsByTagName("link")
+       , i = elts.length
+       , localization
+       ;
+       
+       while (i--) {
+               var
+                 elt = elts[i]
+               , rel = (elt.getAttribute("rel") || 
"")[$to_lowercase]().split(/\s+/)
+               ;
+               
+               if (l10n_js_media_type.test(elt.type)) {
+                       if (array_index_of.call(rel, "localizations") !== -1) {
+                               // multiple localizations
+                               load(elt.getAttribute("href"));
+                       } else if (array_index_of.call(rel, "localization") !== 
-1) {
+                               // single localization
+                               localization = {};
+                               localization[(elt.getAttribute("hreflang") || 
"")[$to_lowercase]()] =
+                                       elt.getAttribute("href");
+                               load(localization);
+                       }
+               }
+       }
+}
+else
+{
+    if(global.l10NLocalFilePath) {
+        load(global.l10NLocalFilePath);
+    }
+    else {
+        var nodeError = "Problem loading localization file. You are most 
likely running in a non-browser environment like Node." + 
+            "If this is the case, you can resolve this error by setting 
global.l10NLocalFilePath to the path of your localization file. ";
+        throw new Error(nodeError); 
+    }
+}
+
+}());
commit 117bb3a837400db593d3b2ce1c1bdea31c374095
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:45:57 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "loleaflet: expand l10n files"
    
    This reverts commit 70bdc4660e53154540781f32007cb044bce131b2.

diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index a749009bb..5be8db596 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -227,10 +227,6 @@ $(builddir)/dist/loleaflet.html: 
$(srcdir)/html/loleaflet.html.m4 $(LOLEAFLET_HT
                -DBUNDLE_CSS="$(abs_builddir)/dist/bundle.css" \
                -DGLOBAL_JS="$(abs_builddir)/dist/global.js" \
                -DL10N_JS="$(abs_builddir)/dist/l10n.js" \
-               
-DLOCALIZATION_JSON="$(abs_builddir)/dist/l10n/localizations.json" \
-               
-DLOCORE_LOCALIZATION_JSON="$(abs_builddir)/dist/l10n/locore-localizations.json"
 \
-               
-DHELP_LOCALIZATION_JSON="$(abs_builddir)/dist/l10n/help-localizations.json" \
-               
-DUNO_LOCALIZATION_JSON="$(abs_builddir)/dist/l10n/uno-localizations.json" \
                -DLOLEAFLET_JS="$(subst $(SPACE),$(COMMA),$(NODE_MODULES_JS) \
                jquery.mCustomScrollbar.js \
                w2ui-1.5.rc1.js \
diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 627321765..bdfa49e5c 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -19,7 +19,7 @@ ifelse(GTKAPP,[true],[define([MOBILEAPP],[true])])
 ifelse(ANDROIDAPP,[true],[define([MOBILEAPP],[true])])
 
 ifelse(MOBILEAPP,[],
-[  // Start listening for Host_PostmessageReady message and save the
+  // Start listening for Host_PostmessageReady message and save the
   // result for future
   window.WOPIpostMessageReady = false;
   var PostMessageReadyListener = function(e) {
@@ -30,11 +30,7 @@ ifelse(MOBILEAPP,[],
     }
   };
   window.addEventListener('message', PostMessageReadyListener, false);
-  window.__globalL10n = syscmd([cat ]LOCALIZATION_JSON);
-  window.__locoreL10n = syscmd([cat ]LOCORE_LOCALIZATION_JSON);
-  window.__helpL10n = syscmd([cat ]HELP_LOCALIZATION_JSON);
-  window.__unoL10n = syscmd([cat ]UNO_LOCALIZATION_JSON);
-])dnl
+)dnl
 
 var Base64ToArrayBuffer = function(base64Str) {
   var binStr = atob(base64Str);
@@ -175,10 +171,6 @@ ifelse(MOBILEAPP,[true],
       window.tileSize = 256;])
 syscmd([cat ]GLOBAL_JS)dnl
 syscmd([cat ]L10N_JS)dnl
-      delete window.__globalL10n;
-      delete window.__locoreL10n;
-      delete window.__helpL10n;
-      delete window.__unoL10n;
     </script>
   <script defer>
 
commit 869dd9385192c3f8528fc3b6756cec7cec9a18e3
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:45:46 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "loleaflet: remove 'link rel="localizations"' tags"
    
    This reverts commit a5536109afc50bca57a5cd39f9a48f2d8d51b1d1.

diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index b14a40141..627321765 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -60,6 +60,18 @@ ifelse(MOBILEAPP,[true],
   ])]dnl
 )dnl
 <!--%BRANDING_CSS%--> <!-- add your logo here -->
+ifelse(MOBILEAPP,[true],
+  [<link rel="localizations" href="l10n/uno-localizations-override.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" href="l10n/localizations.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" href="l10n/locore-localizations.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" href="l10n/help-localizations.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" href="l10n/uno-localizations.json" 
type="application/vnd.oftn.l10n+json"/>],
+  [<link rel="localizations" 
href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/uno-localizations-override.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" 
href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/localizations.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" 
href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/locore-localizations.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" 
href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/help-localizations.json" 
type="application/vnd.oftn.l10n+json"/>
+   <link rel="localizations" 
href="%SERVICE_ROOT%/loleaflet/%VERSION%/l10n/uno-localizations.json" 
type="application/vnd.oftn.l10n+json"/>]
+)dnl
 </head>
 
   <body style="user-select: none;">
commit b842679e9aa03f09aef91c98c3d1e8fb2962e26d
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:45:36 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "loleaflet: load l10n files according to parameter "lang""
    
    This reverts commit 668b837c70b1d2e8d13d97c173b7a8131fc75a04.

diff --git a/loleaflet/js/l10n.js b/loleaflet/js/l10n.js
index d9ca75506..0057eed74 100644
--- a/loleaflet/js/l10n.js
+++ b/loleaflet/js/l10n.js
@@ -18,7 +18,6 @@ var
   undef_type = "undefined"
 , string_type = "string"
 , nav = {}
-, lang = {}
 , String_ctr = String
 , has_own_prop = Object.prototype.hasOwnProperty
 , load_queues = {}
@@ -189,7 +188,6 @@ var
 try
 {
     nav = self.navigator;
-    lang = self.getParameterByName('lang');
 }
 catch(selfNotFoundException)
 {
@@ -242,7 +240,7 @@ if (!browserless && typeof XMLHttpRequest === undef_type && 
typeof ActiveXObject
 }
 
 String_ctr[$default_locale] = String_ctr[$default_locale] || "";
-String_ctr[$locale] = nav && lang && (lang) || "en";
+String_ctr[$locale] = nav && (nav.language || nav.userLanguage) || "";
 
 if (!browserless || typeof document !== undef_type) {
        var
@@ -270,11 +268,6 @@ if (!browserless || typeof document !== undef_type) {
                        }
                }
        }
-
-       load(self.__globalL10n);
-       load(self.__locoreL10n);
-       load(self.__helpL10n);
-       load(self.__unoL10n);
 }
 else
 {
diff --git a/loleaflet/src/errormessages.js b/loleaflet/src/errormessages.js
index c2ac2dd74..3381b9126 100644
--- a/loleaflet/src/errormessages.js
+++ b/loleaflet/src/errormessages.js
@@ -1,10 +1,15 @@
 /* -*- js-indent-level: 8 -*- */
 
-/* global vex _ */
+/* global vex _ getParameterByName */
 var errorMessages = {};
 
 vex.defaultOptions.className = 'vex-theme-plain';
 
+var lang = getParameterByName('lang');
+if (lang) {
+       String.locale = lang;
+}
+
 errorMessages.diskfull = _('No disk space left on server, please contact the 
server administrator to continue.');
 errorMessages.emptyhosturl = _('The host URL is empty. The loolwsd server is 
probably misconfigured, please contact the administrator.');
 errorMessages.limitreached = _('This is an unsupported version of 
{productname}. To avoid the impression that it is suitable for deployment in 
enterprises, this message appears when more than {docs} documents or 
{connections} connections are in use concurrently');
commit 153e2d06fac3f37da33a0e981aad83eb107d8dd0
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:45:26 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "loleaflet: uglify l10n.js"
    
    This reverts commit 3aebf7fea9561416a7c904a16712dba254120989.

diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index cec7f74d9..a749009bb 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -198,10 +198,6 @@ $(builddir)/dist/global.js: $(srcdir)/js/global.js
        @echo "Uglify global.js file..."
        @NODE_PATH=$(abs_builddir)/node_modules $(NODE) 
node_modules/uglify-js/bin/uglifyjs $< --output $@
 
-$(builddir)/dist/l10n.js: $(srcdir)/js/l10n.js
-       @echo "Uglify l10n.js file..."
-       @NODE_PATH=$(abs_builddir)/node_modules $(NODE) 
node_modules/uglify-js/bin/uglifyjs $< --output $@
-
 $(builddir)/dist/bundle.js: $(NODE_MODULES_JS_SRC) \
        $(LOLEAFLET_PREFIX)/dist/loleaflet-src.js \
        $(builddir)/dist/global.js \
commit 8ccc087b18f9717a9f49dbd03e190a27c7b93e9d
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:45:16 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "loleaflet: minify l10n files"
    
    This reverts commit 88a8810ee79215f706c3394bf92072a9dea2c068.

diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index fd4ae378e..cec7f74d9 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -298,13 +298,9 @@ $(builddir)/dist/images/%.png: 
$(JQUERY_MINIFIED_IMAGE_PATH)/%.png
        @mkdir -p $(dir $@)
        @cp $< $@
 
-$(builddir)/dist/l10n/%.json: $(srcdir)/l10n/%.json
+$(builddir)/dist/l10n/%: $(srcdir)/l10n/%
        @mkdir -p $(dir $@)
-if ENABLE_DEBUG
        @cp $< $@
-else
-       @tr -d '[:space:]' <$<  >$@
-endif
 
 $(builddir)/dist/admin/%: $(srcdir)/admin/%
        @mkdir -p $(dir $@)
commit 3f95b8153500a6ca9e8e1bc76f852523f7f9aba2
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:44:58 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "wsd: use a tiny parser, variable substitution"
    
    This reverts commit ed89931ae8ceff62b720a31cf1e163eeee3280fd.

diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 64ff9f618..b14a40141 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -54,12 +54,12 @@ ifelse(MOBILEAPP,[true],
     [<style>syscmd([cat ]BUNDLE_CSS)</style>
   ])],
   [ifelse(DEBUG,[true],
-    foreachq([fileCSS],[LOLEAFLET_CSS],[<link rel="stylesheet" 
href="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/fileCSS" />
+    foreachq([fileCSS],[LOLEAFLET_CSS],[<link rel="stylesheet" 
href="%SERVICE_ROOT%/loleaflet/%VERSION%/fileCSS" />
   ]),
     [<style>syscmd([cat ]BUNDLE_CSS)</style>
   ])]dnl
 )dnl
-<%BRANDING_CSS%> <!-- add your logo here -->
+<!--%BRANDING_CSS%--> <!-- add your logo here -->
 </head>
 
   <body style="user-select: none;">
@@ -100,9 +100,9 @@ ifelse(MOBILEAPP,[true],
      </tr>
     </table>
 
-    <%DOCUMENT_SIGNING_DIV%>
+    <!--%DOCUMENT_SIGNING_DIV%-->
     <script>
-      window.documentSigningURL = '<%DOCUMENT_SIGNING_URL%>';
+      window.documentSigningURL = '%DOCUMENT_SIGNING_URL%';
     </script>
 
     <input id="insertgraphic" type="file" style="position: fixed; top: -100em">
@@ -152,14 +152,14 @@ ifelse(MOBILEAPP,[true],
       window.outOfFocusTimeoutSecs = 1000000;
       window.idleTimeoutSecs = 1000000;
       window.tileSize = 256;],
-     [window.host = '<%HOST%>';
-      window.serviceRoot = '<%SERVICE_ROOT%>';
-      window.accessToken = '<%ACCESS_TOKEN%>';
-      window.accessTokenTTL = '<%ACCESS_TOKEN_TTL%>';
-      window.accessHeader = '<%ACCESS_HEADER%>';
-      window.loleafletLogging = '<%LOLEAFLET_LOGGING%>';
-      window.outOfFocusTimeoutSecs = <%OUT_OF_FOCUS_TIMEOUT_SECS%>;
-      window.idleTimeoutSecs = <%IDLE_TIMEOUT_SECS%>;
+     [window.host = '%HOST%';
+      window.serviceRoot = '%SERVICE_ROOT%';
+      window.accessToken = '%ACCESS_TOKEN%';
+      window.accessTokenTTL = '%ACCESS_TOKEN_TTL%';
+      window.accessHeader = '%ACCESS_HEADER%';
+      window.loleafletLogging = '%LOLEAFLET_LOGGING%';
+      window.outOfFocusTimeoutSecs = %OUT_OF_FOCUS_TIMEOUT_SECS%;
+      window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;
       window.tileSize = 256;])
 syscmd([cat ]GLOBAL_JS)dnl
 syscmd([cat ]L10N_JS)dnl
@@ -207,10 +207,10 @@ ifelse(MOBILEAPP,[true],
   [    <script src="bundle.js" defer></script>
   ]),
   ifelse(DEBUG,[true],foreachq([fileJS],[LOLEAFLET_JS],
-  [    <script src="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/fileJS" 
defer></script>
+  [    <script src="%SERVICE_ROOT%/loleaflet/%VERSION%/fileJS" defer></script>
   ]),
-  [    <script src="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/bundle.js" 
defer></script>
+  [    <script src="%SERVICE_ROOT%/loleaflet/%VERSION%/bundle.js" 
defer></script>
   ])
 )dnl
-    <%BRANDING_JS%> <!-- logo onclick handler -->
+    <!--%BRANDING_JS%--> <!-- logo onclick handler -->
 </body></html>
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 7c297deb1..07ee9c4cd 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -567,26 +567,6 @@ constexpr char BRANDING[] = "branding";
 constexpr char BRANDING_UNSUPPORTED[] = "branding-unsupported";
 #endif
 
-void FileServerRequestHandler::getToken(std::istream& istr, std::string& token)
-{
-    token.clear();
-    int chr = istr.get();
-    if (chr != -1)
-    {
-        if (chr == '<' && istr.peek() == '%')
-        {
-            token += "<%";
-            istr.get();
-        }
-        else if (chr == '%' && istr.peek() == '>')
-        {
-            token += "%>";
-            istr.get();
-        }
-        else token += (char) chr;
-    }
-}
-
 void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, 
Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket)
 {
     const auto host = ((LOOLWSD::isSSLEnabled() || 
LOOLWSD::isSSLTermination()) ? "wss://" : "ws://") + 
(LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName);
@@ -631,6 +611,13 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
         }
     }
 
+    Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN%"), 
escapedAccessToken);
+    Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN_TTL%"), 
std::to_string(tokenTtl));
+    Poco::replaceInPlace(preprocess, std::string("%ACCESS_HEADER%"), 
escapedAccessHeader);
+    Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
+    Poco::replaceInPlace(preprocess, std::string("%VERSION%"), 
std::string(LOOLWSD_VERSION_HASH));
+    Poco::replaceInPlace(preprocess, std::string("%SERVICE_ROOT%"), 
LOOLWSD::ServiceRoot);
+
     static const std::string linkCSS("<link rel=\"stylesheet\" 
href=\"%s/loleaflet/" LOOLWSD_VERSION_HASH "/%s.css\">");
     static const std::string scriptJS("<script src=\"%s/loleaflet/" 
LOOLWSD_VERSION_HASH "/%s.js\"></script>");
 
@@ -648,6 +635,9 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
     }
 #endif
 
+    Poco::replaceInPlace(preprocess, std::string("<!--%BRANDING_CSS%-->"), 
brandCSS);
+    Poco::replaceInPlace(preprocess, std::string("<!--%BRANDING_JS%-->"), 
brandJS);
+
     // Customization related to document signing.
     std::string documentSigningDiv;
     const std::string documentSigningURL = 
config.getString("per_document.document_signing_url", "");
@@ -655,125 +645,15 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
     {
         documentSigningDiv = "<div id=\"document-signing-bar\"></div>";
     }
+    Poco::replaceInPlace(preprocess, 
std::string("<!--%DOCUMENT_SIGNING_DIV%-->"), documentSigningDiv);
+    Poco::replaceInPlace(preprocess, std::string("%DOCUMENT_SIGNING_URL%"), 
documentSigningURL);
 
-    enum class ParseState
-    {
-        None,
-        Subs,
-        L10n
-    };
-
-    std::string token;
-    std::ostringstream ostr;
-    std::stringstream varSubs, varL10n;
-    std::istringstream istr(preprocess);
-    ParseState state = ParseState::None;
-
-    getToken(istr, token);
-    while (!token.empty())
-    {
-        if (token == "<%")
-        {
-            if (state == ParseState::None)
-            {
-                state = ParseState::Subs;
-                varSubs.str("");
-                varSubs.clear();
-            }
-            else ostr << token;
-        }
-        else if (token == "%>")
-        {
-            if (state == ParseState::Subs)
-            {
-                std::string var = varSubs.str();
-                if (var == "ACCESS_TOKEN")
-                {
-                    ostr << escapedAccessToken;
-                }
-                else if (var == "ACCESS_TOKEN_TTL")
-                {
-                    ostr << tokenTtl;
-                }
-                else if (var == "ACCESS_HEADER")
-                {
-                    ostr << escapedAccessHeader;
-                }
-                else if (var == "HOST")
-                {
-                    ostr << host;
-                }
-                else if (var == "VERSION")
-                {
-                    ostr << LOOLWSD_VERSION_HASH;
-                }
-                else if (var == "SERVICE_ROOT")
-                {
-                    ostr << LOOLWSD::ServiceRoot;
-                }
-                else if (var == "LOLEAFLET_LOGGING")
-                {
-                    ostr << config.getString("loleaflet_logging", "false");
-                }
-                else if (var == "OUT_OF_FOCUS_TIMEOUT_SECS")
-                {
-                    ostr << 
config.getString("per_view.out_of_focus_timeout_secs", "60");
-                }
-                else if (var == "IDLE_TIMEOUT_SECS")
-                {
-                    ostr << config.getString("per_view.idle_timeout_secs", 
"900");
-                }
-                else if (var == "DOCUMENT_SIGNING_DIV")
-                {
-                    ostr << documentSigningDiv;
-                }
-                else if (var == "DOCUMENT_SIGNING_URL")
-                {
-                    ostr << documentSigningURL;
-                }
-                else if (var == "BRANDING_CSS")
-                {
-                    ostr << brandCSS;
-                }
-                else if (var == "BRANDING_JS")
-                {
-                    ostr << brandJS;
-                }
-                else ostr << var;
-
-                state = ParseState::None;
-            }
-            else ostr << token;
-        }
-        else
-        {
-            switch (state)
-            {
-                case ParseState::None:
-                    ostr << token;
-                    break;
-
-                case ParseState::Subs:
-                    varSubs << token;
-                    break;
-
-                case ParseState::L10n:
-                    varL10n << token;
-                    break;
-            }
-        }
-
-        getToken(istr, token);
-    }
-
-    if (state == ParseState::Subs)
-    {
-        ostr << varSubs.str();
-    }
-    else if (state == ParseState::L10n)
-    {
-        ostr << varL10n.str();
-    }
+    const auto loleafletLogging = config.getString("loleaflet_logging", 
"false");
+    Poco::replaceInPlace(preprocess, std::string("%LOLEAFLET_LOGGING%"), 
loleafletLogging);
+    const std::string outOfFocusTimeoutSecs= 
config.getString("per_view.out_of_focus_timeout_secs", "60");
+    Poco::replaceInPlace(preprocess, 
std::string("%OUT_OF_FOCUS_TIMEOUT_SECS%"), outOfFocusTimeoutSecs);
+    const std::string idleTimeoutSecs= 
config.getString("per_view.idle_timeout_secs", "900");
+    Poco::replaceInPlace(preprocess, std::string("%IDLE_TIMEOUT_SECS%"), 
idleTimeoutSecs);
 
     const std::string mimeType = "text/html";
 
@@ -784,7 +664,7 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
         << "User-Agent: " << WOPI_AGENT_STRING << "\r\n"
         << "Cache-Control:max-age=11059200\r\n"
         << "ETag: \"" LOOLWSD_VERSION_HASH "\"\r\n"
-        << "Content-Length: " << ostr.tellp() << "\r\n"
+        << "Content-Length: " << preprocess.size() << "\r\n"
         << "Content-Type: " << mimeType << "\r\n"
         << "X-Content-Type-Options: nosniff\r\n"
         << "X-XSS-Protection: 1; mode=block\r\n"
@@ -901,7 +781,7 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
     }
 
     oss << "\r\n"
-        << ostr.str();
+        << preprocess;
 
     socket->send(oss.str());
     LOG_DBG("Sent file: " << relPath << ": " << preprocess);
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp
index 637424468..b415eed65 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -20,7 +20,6 @@ class FileServerRequestHandler
 {
     static std::string getRequestPathname(const Poco::Net::HTTPRequest& 
request);
 
-    static void getToken(std::istream&, std::string&);
     static void preprocessFile(const Poco::Net::HTTPRequest& request, 
Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket);
     static void preprocessAdminFile(const Poco::Net::HTTPRequest& request, 
const std::shared_ptr<StreamSocket>& socket);
 public:
commit 7bd54ab67743764803c4cdec1d7522cec92cd668
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:44:47 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 18:24:25 2019 +0100

    Revert "No FileServer involved for the mobile apps, can't use <%FOO%> 
things"
    
    This reverts commit c8aedbc21877b0c18791f20247b94b31fef8d99f.

diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 6cdaf42bf..64ff9f618 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -57,11 +57,9 @@ ifelse(MOBILEAPP,[true],
     foreachq([fileCSS],[LOLEAFLET_CSS],[<link rel="stylesheet" 
href="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/fileCSS" />
   ]),
     [<style>syscmd([cat ]BUNDLE_CSS)</style>
-  ])
-  <%BRANDING_CSS%> <!-- add your logo here -->
-  ]dnl
+  ])]dnl
 )dnl
-
+<%BRANDING_CSS%> <!-- add your logo here -->
 </head>
 
   <body style="user-select: none;">
@@ -213,6 +211,6 @@ ifelse(MOBILEAPP,[true],
   ]),
   [    <script src="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/bundle.js" 
defer></script>
   ])
-  <%BRANDING_JS%> <!-- logo onclick handler -->
 )dnl
+    <%BRANDING_JS%> <!-- logo onclick handler -->
 </body></html>
commit 081da013b552dbbf149698133384645c3e8d6b12
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:28:14 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:28:14 2019 +0100

    Revert "configure: add Boost.Locale library"
    
    This reverts commit b1bec2f5005049204badee639ece50012d631933.

diff --git a/.gitignore b/.gitignore
index ab93d7460..52ee34543 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ libtool
 ltmain.sh
 missing
 stamp-h1
+m4
 debian/loolwsd.postinst
 common/support-public-key.hpp
 
diff --git a/autogen.sh b/autogen.sh
index 6ce4cbd65..f5043bec5 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -22,7 +22,7 @@ elif test `uname -s` = Darwin; then
     glibtoolize || failed "Can't find glibtoolize. For instance use the one 
from https://brew.sh, 'brew install libtool', or build GNU libtool yourself."
 fi
 
-aclocal -I m4 || failed "aclocal"
+aclocal || failed "aclocal"
 
 autoheader || failed "autoheader"
 
diff --git a/configure.ac b/configure.ac
index dc4a51977..b99020a7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,9 +179,6 @@ AC_ARG_ENABLE([werror],
 AC_ARG_ENABLE([vereign],
             AS_HELP_STRING([--enable-vereign],
                           [Set Vereign document_signing_url configuration key 
to the default app.vereign.com.]))
-
-AX_BOOST_BASE(1.47)
-
 # Handle options
 AS_IF([test "$enable_debug" = yes -a -n "$with_poco_libs"],
       [POCO_DEBUG_SUFFIX=d],
@@ -678,8 +675,6 @@ fi
 
 AC_SUBST(ENABLE_SETCAP)
 
-AX_BOOST_LOCALE
-
 AC_CONFIG_LINKS([discovery.xml:discovery.xml])
 AC_CONFIG_LINKS([loolkitconfig.xcu:loolkitconfig.xcu])
 AC_CONFIG_LINKS([loleaflet/package.json:loleaflet/package.json])
diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4
deleted file mode 100644
index 94909a52f..000000000
--- a/m4/ax_boost_base.m4
+++ /dev/null
@@ -1,266 +0,0 @@
-# ===========================================================================
-#       http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# DESCRIPTION
-#
-#   Test for the Boost C++ libraries of a particular version (or newer)
-#
-#   If no path to the installed boost library is given the macro searches
-#   under /usr, /usr/local, /opt and /opt/local and evaluates the
-#   $BOOST_ROOT environment variable. Further documentation is available at
-#   <http://randspringer.de/boost/index.html>.
-#
-#   This macro calls:
-#
-#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
-#
-#   And sets:
-#
-#     HAVE_BOOST
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Thomas Porschberg <tho...@randspringer.de>
-#   Copyright (c) 2009 Peter Adolphs
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 20
-
-AC_DEFUN([AX_BOOST_BASE],
-[
-AC_ARG_WITH([boost],
-  [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
-    [use Boost library from a standard location (ARG=yes),
-     from the specified location (ARG=<path>),
-     or disable it (ARG=no)
-     @<:@ARG=yes@:>@ ])],
-    [
-    if test "$withval" = "no"; then
-        want_boost="no"
-    elif test "$withval" = "yes"; then
-        want_boost="yes"
-        ac_boost_path=""
-    else
-        want_boost="yes"
-        ac_boost_path="$withval"
-    fi
-    ],
-    [want_boost="yes"])
-
-
-AC_ARG_WITH([boost-libdir],
-        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
-        [Force given directory for boost libraries. Note that this will 
override library path detection, so use this parameter only if default library 
detection fails and you know exactly where your boost libraries are located.]),
-        [
-        if test -d "$withval"
-        then
-                ac_boost_lib_path="$withval"
-        else
-                AC_MSG_ERROR(--with-boost-libdir expected directory name)
-        fi
-        ],
-        [ac_boost_lib_path=""]
-)
-
-if test "x$want_boost" = "xyes"; then
-    boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
-    boost_lib_version_req_shorten=`expr $boost_lib_version_req : 
'\([[0-9]]*\.[[0-9]]*\)'`
-    boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
-    boost_lib_version_req_minor=`expr $boost_lib_version_req : 
'[[0-9]]*\.\([[0-9]]*\)'`
-    boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : 
'[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
-    if test "x$boost_lib_version_req_sub_minor" = "x" ; then
-        boost_lib_version_req_sub_minor="0"
-        fi
-    WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  
$boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
-    AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
-    succeeded=no
-
-    dnl On 64-bit systems check for system libraries in both lib64 and lib.
-    dnl The former is specified by FHS, but e.g. Debian does not adhere to
-    dnl this (as it rises problems for generic multi-arch support).
-    dnl The last entry in the list is chosen by default when no libraries
-    dnl are found, e.g. when only header-only libraries are installed!
-    libsubdirs="lib"
-    ax_arch=`uname -m`
-    if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = ppc64le -o 
$ax_arch = s390x -o $ax_arch = sparc64 -o $ax_arch = aarch64; then
-        libsubdirs="lib64 lib lib64"
-    fi
-
-    dnl first we check the system location for boost libraries
-    dnl this location is chosen if boost libraries are installed with the 
--layout=system option
-    dnl or if you install boost with RPM
-    if test "$ac_boost_path" != ""; then
-        BOOST_CPPFLAGS="-I$ac_boost_path/include"
-        for ac_boost_path_tmp in $libsubdirs; do
-                if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
-                        BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
-                        break
-                fi
-        done
-    else
-        if test "$cross_compiling" != yes; then
-            ac_boost_paths='/usr /usr/local /opt /opt/local'
-        else
-            ac_boost_paths="/usr/$host/sys-root/mingw"
-        fi
-        for ac_boost_path_tmp in $ac_boost_paths ; do
-            if test -d "$ac_boost_path_tmp/include/boost" && test -r 
"$ac_boost_path_tmp/include/boost"; then
-                for libsubdir in $libsubdirs ; do
-                    if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* 
>/dev/null 2>&1 ; then break; fi
-                done
-                BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
-                BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
-                break;
-            fi
-        done
-    fi
-
-    dnl overwrite ld flags if we have required special directory with
-    dnl --with-boost-libdir parameter
-    if test "$ac_boost_lib_path" != ""; then
-       BOOST_LDFLAGS="-L$ac_boost_lib_path"
-    fi
-
-    CPPFLAGS_SAVED="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
-    export CPPFLAGS
-
-    LDFLAGS_SAVED="$LDFLAGS"
-    LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
-    export LDFLAGS
-
-    AC_REQUIRE([AC_PROG_CXX])
-    AC_LANG_PUSH(C++)
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-    @%:@include <boost/version.hpp>
-    ]], [[
-    #if BOOST_VERSION >= $WANT_BOOST_VERSION
-    // Everything is okay
-    #else
-    #  error Boost version is too old
-    #endif
-    ]])],[
-        AC_MSG_RESULT(yes)
-    succeeded=yes
-    found_system=yes
-        ],[
-        ])
-    AC_LANG_POP([C++])
-
-
-
-    dnl if we found no boost with system layout we search for boost libraries
-    dnl built and installed without the --layout=system option or for a 
staged(not installed) version
-    if test "x$succeeded" != "xyes"; then
-        _version=0
-        if test "$ac_boost_path" != ""; then
-            if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
-                for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
-                    _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 
's/\/include\/boost-//' | sed 's/_/./'`
-                    V_CHECK=`expr $_version_tmp \> $_version`
-                    if test "$V_CHECK" = "1" ; then
-                        _version=$_version_tmp
-                    fi
-                    VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
-                    
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
-                done
-            fi
-        else
-            if test "$cross_compiling" != yes; then
-                ac_boost_paths='/usr /usr/local /opt /opt/local'
-            else
-                ac_boost_paths="/usr/$host/sys-root/mingw"
-            fi
-            for ac_boost_path in $ac_boost_paths ; do
-                if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
-                    for i in `ls -d $ac_boost_path/include/boost-* 
2>/dev/null`; do
-                        _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 
's/\/include\/boost-//' | sed 's/_/./'`
-                        V_CHECK=`expr $_version_tmp \> $_version`
-                        if test "$V_CHECK" = "1" ; then
-                            _version=$_version_tmp
-                            best_path=$ac_boost_path
-                        fi
-                    done
-                fi
-            done
-
-            VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
-            BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
-            if test "$ac_boost_lib_path" = ""; then
-                for libsubdir in $libsubdirs ; do
-                    if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; 
then break; fi
-                done
-                BOOST_LDFLAGS="-L$best_path/$libsubdir"
-            fi
-
-            if test "x$BOOST_ROOT" != "x"; then
-                for libsubdir in $libsubdirs ; do
-                    if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 
2>&1 ; then break; fi
-                done
-                if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d 
"$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
-                    version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
-                    stage_version=`echo $version_dir | sed 's/boost_//' | sed 
's/_/./g'`
-                        stage_version_shorten=`expr $stage_version : 
'\([[0-9]]*\.[[0-9]]*\)'`
-                    V_CHECK=`expr $stage_version_shorten \>\= $_version`
-                    if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; 
then
-                        AC_MSG_NOTICE(We will use a staged boost library from 
$BOOST_ROOT)
-                        BOOST_CPPFLAGS="-I$BOOST_ROOT"
-                        BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
-                    fi
-                fi
-            fi
-        fi
-
-        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
-        export CPPFLAGS
-        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
-        export LDFLAGS
-
-        AC_LANG_PUSH(C++)
-            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-        @%:@include <boost/version.hpp>
-        ]], [[
-        #if BOOST_VERSION >= $WANT_BOOST_VERSION
-        // Everything is okay
-        #else
-        #  error Boost version is too old
-        #endif
-        ]])],[
-            AC_MSG_RESULT(yes)
-        succeeded=yes
-        found_system=yes
-            ],[
-            ])
-        AC_LANG_POP([C++])
-    fi
-
-    if test "$succeeded" != "yes" ; then
-        if test "$_version" = "0" ; then
-            AC_MSG_NOTICE([[We could not detect the boost libraries (version 
$boost_lib_version_req_shorten or higher). If you have a staged boost library 
(still not installed) please specify \$BOOST_ROOT in your environment and do 
not give a PATH to --with-boost option.  If you are sure you have boost 
installed, then check your version number looking in <boost/version.hpp>. See 
http://randspringer.de/boost for more documentation.]])
-        else
-            AC_MSG_NOTICE([Your boost libraries seems to old (version 
$_version).])
-        fi
-        # execute ACTION-IF-NOT-FOUND (if present):
-        ifelse([$3], , :, [$3])
-    else
-        AC_SUBST(BOOST_CPPFLAGS)
-        AC_SUBST(BOOST_LDFLAGS)
-        AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
-        # execute ACTION-IF-FOUND (if present):
-        ifelse([$2], , :, [$2])
-    fi
-
-    CPPFLAGS="$CPPFLAGS_SAVED"
-    LDFLAGS="$LDFLAGS_SAVED"
-fi
-
-])
diff --git a/m4/ax_boost_locale.m4 b/m4/ax_boost_locale.m4
deleted file mode 100644
index adaedf09e..000000000
--- a/m4/ax_boost_locale.m4
+++ /dev/null
@@ -1,119 +0,0 @@
-# ===========================================================================
-#     https://www.gnu.org/software/autoconf-archive/ax_boost_locale.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_BOOST_LOCALE
-#
-# DESCRIPTION
-#
-#   Test for System library from the Boost C++ libraries. The macro requires
-#   a preceding call to AX_BOOST_BASE. Further documentation is available at
-#   <http://randspringer.de/boost/index.html>.
-#
-#   This macro calls:
-#
-#     AC_SUBST(BOOST_LOCALE_LIB)
-#
-#   And sets:
-#
-#     HAVE_BOOST_LOCALE
-#
-# LICENSE
-#
-#   Copyright (c) 2012 Xiyue Deng <manp...@gmail.com>
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 2
-
-AC_DEFUN([AX_BOOST_LOCALE],
-[
-       AC_ARG_WITH([boost-locale],
-       AS_HELP_STRING([--with-boost-locale@<:@=special-lib@:>@],
-                   [use the Locale library from boost - it is possible to 
specify a certain library for the linker
-                        e.g. --with-boost-locale=boost_locale-gcc-mt ]),
-        [
-        if test "$withval" = "no"; then
-                       want_boost="no"
-        elif test "$withval" = "yes"; then
-            want_boost="yes"
-            ax_boost_user_locale_lib=""
-        else
-                   want_boost="yes"
-               ax_boost_user_locale_lib="$withval"
-               fi
-        ],
-        [want_boost="yes"]
-       )
-
-       if test "x$want_boost" = "xyes"; then
-        AC_REQUIRE([AC_PROG_CC])
-        AC_REQUIRE([AC_CANONICAL_BUILD])
-               CPPFLAGS_SAVED="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
-               export CPPFLAGS
-
-               LDFLAGS_SAVED="$LDFLAGS"
-               LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
-               export LDFLAGS
-
-        AC_CACHE_CHECK(whether the Boost::Locale library is available,
-                                          ax_cv_boost_locale,
-        [AC_LANG_PUSH([C++])
-                        CXXFLAGS_SAVE=$CXXFLAGS
-
-                        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include 
<boost/locale.hpp>]],
-                                   [[boost::locale::generator gen;
-                                   std::locale::global(gen(""));]])],
-                   ax_cv_boost_locale=yes, ax_cv_boost_locale=no)
-                        CXXFLAGS=$CXXFLAGS_SAVE
-             AC_LANG_POP([C++])
-               ])
-               if test "x$ax_cv_boost_locale" = "xyes"; then
-                       AC_SUBST(BOOST_CPPFLAGS)
-
-                       AC_DEFINE(HAVE_BOOST_LOCALE,,[define if the 
Boost::Locale library is available])
-            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
-
-                       LDFLAGS_SAVE=$LDFLAGS
-            if test "x$ax_boost_user_locale_lib" = "x"; then
-                for libextension in `ls $BOOSTLIBDIR/libboost_locale*.so* 
$BOOSTLIBDIR/libboost_locale*.dylib* $BOOSTLIBDIR/libboost_locale*.a* 
2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_locale.*\)\.so.*$;\1;' -e 
's;^lib\(boost_locale.*\)\.dylib.*$;\1;' -e 
's;^lib\(boost_locale.*\)\.a.*$;\1;'` ; do
-                     ax_lib=${libextension}
-                                   AC_CHECK_LIB($ax_lib, exit,
-                                 [BOOST_LOCALE_LIB="-l$ax_lib"; 
AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
-                                 [link_locale="no"])
-                               done
-                if test "x$link_locale" != "xyes"; then
-                for libextension in `ls $BOOSTLIBDIR/boost_locale*.dll* 
$BOOSTLIBDIR/boost_locale*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 
's;^\(boost_locale.*\)\.dll.*$;\1;' -e 's;^\(boost_locale.*\)\.a.*$;\1;'` ; do
-                     ax_lib=${libextension}
-                                   AC_CHECK_LIB($ax_lib, exit,
-                                 [BOOST_LOCALE_LIB="-l$ax_lib"; 
AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
-                                 [link_locale="no"])
-                               done
-                fi
-
-            else
-               for ax_lib in $ax_boost_user_locale_lib 
boost_locale-$ax_boost_user_locale_lib; do
-                                     AC_CHECK_LIB($ax_lib, exit,
-                                   [BOOST_LOCALE_LIB="-l$ax_lib"; 
AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
-                                   [link_locale="no"])
-                  done
-
-            fi
-            if test "x$ax_lib" = "x"; then
-                AC_MSG_ERROR(Could not find a version of the library!)
-            fi
-                       if test "x$link_locale" = "xno"; then
-                               AC_MSG_ERROR(Could not link against $ax_lib !)
-                       fi
-               fi
-
-               CPPFLAGS="$CPPFLAGS_SAVED"
-       LDFLAGS="$LDFLAGS_SAVED"
-       fi
-])
commit c2aebb05f201e588c9992f1d154c36dc5330c6ad
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:28:01 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:28:01 2019 +0100

    Revert "m4: fix 'char exit()' conflicts with built-in declaration 'void 
exit(int)'"
    
    This reverts commit 82207d6967349de3e4df880a5279b0efe3319f9a.

diff --git a/m4/ax_boost_locale.m4 b/m4/ax_boost_locale.m4
index 30e763e78..adaedf09e 100644
--- a/m4/ax_boost_locale.m4
+++ b/m4/ax_boost_locale.m4
@@ -84,16 +84,14 @@ AC_DEFUN([AX_BOOST_LOCALE],
             if test "x$ax_boost_user_locale_lib" = "x"; then
                 for libextension in `ls $BOOSTLIBDIR/libboost_locale*.so* 
$BOOSTLIBDIR/libboost_locale*.dylib* $BOOSTLIBDIR/libboost_locale*.a* 
2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_locale.*\)\.so.*$;\1;' -e 
's;^lib\(boost_locale.*\)\.dylib.*$;\1;' -e 
's;^lib\(boost_locale.*\)\.a.*$;\1;'` ; do
                      ax_lib=${libextension}
-LDFLAGS="$LDFLAGS_SAVE -l$ax_lib"
-AC_LINK_IFELSE([AC_LANG_PROGRAM([#include<boost/locale.hpp>],[boost::locale::pgettext("test","test");])],
+                                   AC_CHECK_LIB($ax_lib, exit,
                                  [BOOST_LOCALE_LIB="-l$ax_lib"; 
AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
                                  [link_locale="no"])
                                done
                 if test "x$link_locale" != "xyes"; then
                 for libextension in `ls $BOOSTLIBDIR/boost_locale*.dll* 
$BOOSTLIBDIR/boost_locale*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 
's;^\(boost_locale.*\)\.dll.*$;\1;' -e 's;^\(boost_locale.*\)\.a.*$;\1;'` ; do
                      ax_lib=${libextension}
-LDFLAGS="$LDFLAGS_SAVE -l$ax_lib"
-AC_LINK_IFELSE([AC_LANG_PROGRAM([#include<boost/locale.hpp>],[boost::locale::pgettext("test","test");])],
+                                   AC_CHECK_LIB($ax_lib, exit,
                                  [BOOST_LOCALE_LIB="-l$ax_lib"; 
AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
                                  [link_locale="no"])
                                done
@@ -101,8 +99,7 @@ 
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include<boost/locale.hpp>],[boost::locale::pge
 
             else
                for ax_lib in $ax_boost_user_locale_lib 
boost_locale-$ax_boost_user_locale_lib; do
-LDFLAGS="$LDFLAGS_SAVE -l$ax_lib"
-AC_LINK_IFELSE([AC_LANG_PROGRAM([#include<boost/locale.hpp>],[boost::locale::pgettext("test","test");])],
+                                     AC_CHECK_LIB($ax_lib, exit,
                                    [BOOST_LOCALE_LIB="-l$ax_lib"; 
AC_SUBST(BOOST_LOCALE_LIB) link_locale="yes"; break],
                                    [link_locale="no"])
                   done
commit 95f4d70ea772bb813b6656c0d4627ec7c0cd11d1
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:27:51 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:27:51 2019 +0100

    Revert "configure: check "msgfmt" installation"
    
    This reverts commit a6b2708ef58fd23dd536606ec8fe4778c285952f.

diff --git a/configure.ac b/configure.ac
index 651a0660e..dc4a51977 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,12 +225,6 @@ else
 fi
 AC_SUBST(ENABLE_BROWSERSYNC)
 
-AC_CHECK_PROGS(MSGFMT, [msgfmt])
-AC_CHECK_PROGS(MSGCAT, [msgcat])
-if test -z "$MSGFMT"; then
-    AC_MSG_ERROR([msgfmt not found. Install GNU gettext])
-fi
-
 if test -n "$with_logfile" ; then
    LOOLWSD_LOGFILE="$with_logfile"
 fi
commit 14c646067a446006ed1fbae8132a4a6399d27e3a
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:27:40 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:27:40 2019 +0100

    Revert "configure: add libraries from Boost Locale to the linker"
    
    This reverts commit 21315768c05fe5fdba85bcab41c4c2032fa8e367.

diff --git a/Makefile.am b/Makefile.am
index c98d482a8..4fd349d76 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -63,7 +63,7 @@ if !ENABLE_DEBUG
 AM_CPPFLAGS += -DNDEBUG
 endif
 
-AM_LDFLAGS = -pthread -Wl,-E,-rpath,/snap/loolwsd/current/usr/lib -lpam 
$(ZLIB_LIBS) $(BOOST_LOCALE_LIB)
+AM_LDFLAGS = -pthread -Wl,-E,-rpath,/snap/loolwsd/current/usr/lib -lpam 
$(ZLIB_LIBS)
 
 if ENABLE_SSL
 AM_LDFLAGS += -lssl -lcrypto
commit 51080df3b9a84cd3572df497a510d7d3fb6cbff8
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:27:27 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:27:27 2019 +0100

    Revert "configure:L10n: compile message catalog to binary format"
    
    This reverts commit 59241a2ea467992adadbacae00a15ec7fe0de2d9.

diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index 3e8d3376a..fd4ae378e 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -1,140 +1,9 @@
 
-LANGUAGES = \
-       ab \
-       af \
-       am \
-       an \
-       anp \
-       ar \
-       as \
-       ast \
-       az \
-       bar \
-       be \
-       bg \
-       bm \
-       bn_IN \
-       bn \
-       bo \
-       br \
-       brx \
-       bs \
-       ca \
-       ca-valencia \
-       ce \
-       cs \
-       cy \
-       da \
-       de \
-       dgo \
-       dsb \
-       dz \
-       el \
-       en_AU \
-       en_GB \
-       en_ZA \
-       eo \
-       es \
-       et \
-       eu \
-       fa \
-       fi \
-       fr \
-       fur \
-       fy \
-       ga \
-       gbm \
-       gd \
-       gl \
-       gug \
-       gu \
-       he \
-       hi \
-       hr \
-       hsb \
-       hu \
-       hy \
-       id \
-       is \
-       it \
-       ja \
-       jv \
-       kab \
-       ka \
-       kk \
-       kl \
-       km \
-       kmr-Latn \
-       kn \
-       kok \
-       ko \
-       ks \
-       ky \
-       lb \
-       lo \
-       lt \
-       lv \
-       mai \
-       mk \
-       ml \
-       mni \
-       ml \
-       mr \
-       mt \
-       my \
-       nah \
-       nb \
-       ne \
-       nl \
-       nn \
-       nqo \
-       nr \
-       nso \
-       oc \
-       om \
-       or \
-       pa_IN \
-       pap_CW \
-       pl \
-       pt_BR \
-       pt \
-       ro \
-       ru \
-       rw \
-       sah \
-       sa_IN \
-       sat \
-       sd \
-       sid \
-       si \
-       sk \
-       sl \
-       sq \
-       ss \
-       st \
-       sv \
-       sw_TZ \
-       ta \
-       te \
-       tg \
-       th \
-       ti \
-       tn \
-       tr \
-       ts \
-       tt \
-       ug \
-       uk \
-       ur \
-       uz \
-       vec \
-       ve \
-       vi \
-       wo \
-       xh \
-       zh_CN \
-       zh_TW \
-       zu
+L10N_PO = $(wildcard $(srcdir)/po/*.po)
+
+if !ENABLE_MOBILEAPP
+L10N_JSON = $(patsubst 
$(srcdir)/po/%.po,$(builddir)/dist/l10n/%.json,$(L10N_PO))
+endif
 
 if ENABLE_IOSAPP
 L10N_IOS_ALL_JS = $(builddir)/dist/l10n-all.js
@@ -174,11 +43,6 @@ LOLEAFLET_ADMIN_SRC = $(shell find $(srcdir)/admin -name 
'*.html')
 LOLEAFLET_ADMIN_ALL = $(shell find $(srcdir)/admin -name '*')
 LOLEAFLET_ADMIN_DST = $(patsubst 
$(srcdir)/admin/%,$(builddir)/dist/admin/%,$(LOLEAFLET_ADMIN_SRC))
 
-define lang_target
-$(1):: $(2)
-
-endef
-
 define file_target
 $(1): $(2)
        @if test -z '$(ENABLE_BROWSERSYNC)'; then \
@@ -218,15 +82,8 @@ LOLEAFLET_CSS =\
 
 LOLEAFLET_CSS_DST = $(foreach file,$(LOLEAFLET_CSS),$(builddir)/dist/$(notdir 
$(file)))
 LOLEAFLET_CSS_M4 = $(strip $(foreach file,$(LOLEAFLET_CSS),$(notdir $(file))))
-LOLEAFLET_MO_DST = $(foreach 
lang,$(LANGUAGES),$(top_builddir)/locale/$(lang)/LC_MESSAGES/loolwsd.mo)
 
 $(eval $(call file_targets,$(LOLEAFLET_CSS)))
-$(eval $(foreach lang,$(LANGUAGES), \
-               $(call 
lang_target,$(top_builddir)/locale/$(lang)/LC_MESSAGES/loolwsd.mo, \
-                       $(srcdir)/po/help-$(lang).po $(srcdir)/po/ui-$(lang).po 
\
-               ) \
-       ) \
-)
 
 NODE_MODULES_JS =\
        node_modules/hammerjs/hammer.min.js \
@@ -270,8 +127,8 @@ if !ENABLE_MOBILEAPP
 ADMIN_BUNDLE = $(builddir)/dist/admin-bundle.js
 endif
 
-build-loleaflet: | \
-       $(LOLEAFLET_MO_DST) \
+build-loleaflet: | $(LOLEAFLET_L10N_DST) \
+       $(L10N_JSON) \
        $(LOLEAFLET_IMAGES_DST) \
        $(JQUERY_LIGHTNESS_DIST_IMAGES) \
        $(JQUERY_MINIFIED_DIST_IMAGES) \
@@ -441,10 +298,13 @@ $(builddir)/dist/images/%.png: 
$(JQUERY_MINIFIED_IMAGE_PATH)/%.png
        @mkdir -p $(dir $@)
        @cp $< $@
 
-$(top_builddir)/locale/%/LC_MESSAGES/loolwsd.mo: $(srcdir)/po/help-%.po 
$(srcdir)/po/ui-%.po
-       @echo "INFO: compiling message catalog $@"
+$(builddir)/dist/l10n/%.json: $(srcdir)/l10n/%.json
        @mkdir -p $(dir $@)
-       @$(MSGCAT) $^ | $(MSGFMT) -o $@ -
+if ENABLE_DEBUG
+       @cp $< $@
+else
+       @tr -d '[:space:]' <$<  >$@
+endif
 
 $(builddir)/dist/admin/%: $(srcdir)/admin/%
        @mkdir -p $(dir $@)
@@ -489,7 +349,6 @@ l10n: pot
 clean-local:
        rm -rf node_modules
        rm -rf $(builddir)/dist
-       rm -rf $(top_builddir)/locale
        rm -rf $(builddir)/build/dist
 
 spec/data/load-test:
commit 6d32ee8e6110941f26d994cc2004d32ae263500b
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:27:17 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:27:17 2019 +0100

    Revert "loleaflet: add LANG variable parameter"
    
    This reverts commit d3e8385fbb5020a6b5d72bcee76243c998b43bb5.

diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 9703776e0..6cdaf42bf 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -209,9 +209,9 @@ ifelse(MOBILEAPP,[true],
   [    <script src="bundle.js" defer></script>
   ]),
   ifelse(DEBUG,[true],foreachq([fileJS],[LOLEAFLET_JS],
-  [    <script src="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/fileJS<%LANG%>" 
defer></script>
+  [    <script src="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/fileJS" 
defer></script>
   ]),
-  [    <script src="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/bundle.js<%LANG%>" 
defer></script>
+  [    <script src="<%SERVICE_ROOT%>/loleaflet/<%VERSION%>/bundle.js" 
defer></script>
   ])
   <%BRANDING_JS%> <!-- logo onclick handler -->
 )dnl
commit b132738476fb9b7b793e888461d3ae35d1ff2caf
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:27:04 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:27:04 2019 +0100

    Revert "wsd: tokenize symbol "_('') _("")""
    
    This reverts commit 6144d55f44c2109d43bc45c408fe4d1ca8f42207.

diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 61259ac05..7c297deb1 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -567,7 +567,7 @@ constexpr char BRANDING[] = "branding";
 constexpr char BRANDING_UNSUPPORTED[] = "branding-unsupported";
 #endif
 
-void FileServerRequestHandler::getToken(std::istringstream& istr, std::string& 
token)
+void FileServerRequestHandler::getToken(std::istream& istr, std::string& token)
 {
     token.clear();
     int chr = istr.get();
@@ -583,33 +583,6 @@ void 
FileServerRequestHandler::getToken(std::istringstream& istr, std::string& t
             token += "%>";
             istr.get();
         }
-        else if (chr == '_' && istr.peek() == '(')
-        {
-            token += "_(";
-            istr.get();
-            chr = istr.peek();
-            switch (chr)
-            {
-                case '\"':
-                    chr = istr.get();
-                    token += (char) chr;
-                break;
-                case '\'':
-                    chr = istr.get();
-                    token += (char) chr;
-                break;
-            }
-        }
-        else if (chr == '"' && istr.peek() == ')')
-        {
-            token += "\")";
-            istr.get();
-        }
-        else if (chr == '\'' && istr.peek() == ')')
-        {
-            token += "')";
-            istr.get();
-        }
         else token += (char) chr;
     }
 }
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp
index 45cf7538b..637424468 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -20,7 +20,7 @@ class FileServerRequestHandler
 {
     static std::string getRequestPathname(const Poco::Net::HTTPRequest& 
request);
 
-    static void getToken(std::istringstream&, std::string&);
+    static void getToken(std::istream&, std::string&);
     static void preprocessFile(const Poco::Net::HTTPRequest& request, 
Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket);
     static void preprocessAdminFile(const Poco::Net::HTTPRequest& request, 
const std::shared_ptr<StreamSocket>& socket);
 public:
commit e78a93e7478177a47f716753d28e6cfbb921f97b
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:26:54 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:26:54 2019 +0100

    Revert "wsd: create a static function "parse""
    
    This reverts commit fcfc257162e106f48b2864820c435fd836588a41.

diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 409a9c540..61259ac05 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -683,74 +683,124 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
         documentSigningDiv = "<div id=\"document-signing-bar\"></div>";
     }
 
-    std::string lang;
-    std::locale locale;
+    enum class ParseState
+    {
+        None,
+        Subs,
+        L10n
+    };
+
+    std::string token;
     std::ostringstream ostr;
+    std::stringstream varSubs, varL10n;
     std::istringstream istr(preprocess);
+    ParseState state = ParseState::None;
 
-    parse(locale, istr, ostr, [&](const std::string& var) {
-        bool result = true;
-        if (var == "ACCESS_TOKEN")
-        {
-            ostr << escapedAccessToken;
-        }
-        else if (var == "ACCESS_TOKEN_TTL")
-        {
-            ostr << tokenTtl;
-        }
-        else if (var == "ACCESS_HEADER")
-        {
-            ostr << escapedAccessHeader;
-        }
-        else if (var == "HOST")
-        {
-            ostr << host;
-        }
-        else if (var == "VERSION")
-        {
-            ostr << LOOLWSD_VERSION_HASH;
-        }
-        else if (var == "SERVICE_ROOT")
-        {
-            ostr << LOOLWSD::ServiceRoot;
-        }
-        else if (var == "LOLEAFLET_LOGGING")
-        {
-            ostr << config.getString("loleaflet_logging", "false");
-        }
-        else if (var == "OUT_OF_FOCUS_TIMEOUT_SECS")
-        {
-            ostr << config.getString("per_view.out_of_focus_timeout_secs", 
"60");
-        }
-        else if (var == "IDLE_TIMEOUT_SECS")
-        {
-            ostr << config.getString("per_view.idle_timeout_secs", "900");
-        }
-        else if (var == "DOCUMENT_SIGNING_DIV")
-        {
-            ostr << documentSigningDiv;
-        }
-        else if (var == "DOCUMENT_SIGNING_URL")
-        {
-            ostr << documentSigningURL;
-        }
-        else if (var == "BRANDING_CSS")
+    getToken(istr, token);
+    while (!token.empty())
+    {
+        if (token == "<%")
         {
-            ostr << brandCSS;
+            if (state == ParseState::None)
+            {
+                state = ParseState::Subs;
+                varSubs.str("");
+                varSubs.clear();
+            }
+            else ostr << token;
         }
-        else if (var == "BRANDING_JS")
+        else if (token == "%>")
         {
-            ostr << brandJS;
+            if (state == ParseState::Subs)
+            {
+                std::string var = varSubs.str();
+                if (var == "ACCESS_TOKEN")
+                {
+                    ostr << escapedAccessToken;
+                }
+                else if (var == "ACCESS_TOKEN_TTL")
+                {
+                    ostr << tokenTtl;
+                }
+                else if (var == "ACCESS_HEADER")
+                {
+                    ostr << escapedAccessHeader;
+                }
+                else if (var == "HOST")
+                {
+                    ostr << host;
+                }
+                else if (var == "VERSION")
+                {
+                    ostr << LOOLWSD_VERSION_HASH;
+                }
+                else if (var == "SERVICE_ROOT")
+                {
+                    ostr << LOOLWSD::ServiceRoot;
+                }
+                else if (var == "LOLEAFLET_LOGGING")
+                {
+                    ostr << config.getString("loleaflet_logging", "false");
+                }
+                else if (var == "OUT_OF_FOCUS_TIMEOUT_SECS")
+                {
+                    ostr << 
config.getString("per_view.out_of_focus_timeout_secs", "60");
+                }
+                else if (var == "IDLE_TIMEOUT_SECS")
+                {
+                    ostr << config.getString("per_view.idle_timeout_secs", 
"900");
+                }
+                else if (var == "DOCUMENT_SIGNING_DIV")
+                {
+                    ostr << documentSigningDiv;
+                }
+                else if (var == "DOCUMENT_SIGNING_URL")
+                {
+                    ostr << documentSigningURL;
+                }
+                else if (var == "BRANDING_CSS")
+                {
+                    ostr << brandCSS;
+                }
+                else if (var == "BRANDING_JS")
+                {
+                    ostr << brandJS;
+                }
+                else ostr << var;
+
+                state = ParseState::None;
+            }
+            else ostr << token;
         }
-        else if (var == "LANG")
+        else
         {
-            if (lang != "en")
-                ostr << "?lang=" << lang;
+            switch (state)
+            {
+                case ParseState::None:
+                    ostr << token;
+                    break;
+
+                case ParseState::Subs:
+                    varSubs << token;
+                    break;
+
+                case ParseState::L10n:
+                    varL10n << token;
+                    break;
+            }
         }
-        else result = false;
 
-        return result;
-    });
+        getToken(istr, token);
+    }
+
+    if (state == ParseState::Subs)
+    {
+        ostr << varSubs.str();
+    }
+    else if (state == ParseState::L10n)
+    {
+        ostr << varL10n.str();
+    }
 
     const std::string mimeType = "text/html";
 
@@ -937,92 +987,4 @@ void FileServerRequestHandler::preprocessAdminFile(const 
HTTPRequest& request,co
     socket->send(oss.str());
 }
 
-void FileServerRequestHandler::parse(const std::locale& locale, 
std::istringstream& istr, std::ostringstream& ostr, const 
std::function<bool(const std::string&)>& funcSubs)
-{
-    enum class ParseState
-    {
-        None,
-        Subs,
-        L10n
-    };
-
-    std::string token;
-    std::stringstream varSubs, varL10n;
-    ParseState state = ParseState::None;
-
-    getToken(istr, token);
-    while (!token.empty())
-    {
-        if (token == "<%")
-        {
-            if (state == ParseState::None)
-            {
-                state = ParseState::Subs;
-                varSubs.str("");
-                varSubs.clear();
-            }
-            else ostr << token;
-        }
-        else if (token == "_(\'")
-        {
-            if (state == ParseState::None)
-            {
-                state = ParseState::L10n;
-                varL10n.str("");
-                varL10n.clear();
-            }
-            else ostr << token;
-        }
-        else if (token == "\')")
-        {
-            if (state == ParseState::L10n)
-            {
-                LOG_INF(locale.name());
-                //ostr << '\'' << 
boost::locale::gettext(varL10n.str().c_str(), locale) << '\'';
-                state = ParseState::None;
-            }
-            else ostr << token;
-        }
-        else if (token == "%>")
-        {
-            if (state == ParseState::Subs)
-            {
-                std::string var = varSubs.str();
-                if (!funcSubs(var))
-                    ostr << var;
-
-                state = ParseState::None;
-            }
-            else ostr << token;
-        }
-        else
-        {
-            switch (state)
-            {
-                case ParseState::None:
-                    ostr << token;
-                    break;
-
-                case ParseState::Subs:
-                    varSubs << token;
-                    break;
-
-                case ParseState::L10n:
-                    varL10n << token;
-                    break;
-            }
-        }
-
-        getToken(istr, token);
-    }
-
-    if (state == ParseState::Subs)
-    {
-        ostr << varSubs.str();
-    }
-    else if (state == ParseState::L10n)
-    {
-        ostr << varL10n.str();
-    }
-}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp
index c5a5133cd..45cf7538b 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -21,7 +21,6 @@ class FileServerRequestHandler
     static std::string getRequestPathname(const Poco::Net::HTTPRequest& 
request);
 
     static void getToken(std::istringstream&, std::string&);
-    static void parse(const std::locale&, std::istringstream&, 
std::ostringstream&, const std::function<bool(const std::string&)>&);
     static void preprocessFile(const Poco::Net::HTTPRequest& request, 
Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket);
     static void preprocessAdminFile(const Poco::Net::HTTPRequest& request, 
const std::shared_ptr<StreamSocket>& socket);
 public:
commit 0087e9fbc3372f82f1ff39b67990e8cbb9157373
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:26:42 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:26:42 2019 +0100

    Revert "wsd: add boost::locale generation and caching"
    
    This reverts commit c2aef686012c4130553a0d36f260b12615408126.

diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index b82becbf1..409a9c540 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -38,9 +38,6 @@
 #include <Poco/StreamCopier.h>
 #include <Poco/StringTokenizer.h>
 #include <Poco/URI.h>
-#include <boost/locale.hpp>
-#include <boost/locale/gnu_gettext.hpp>
-#include <boost/exception/all.hpp>
 
 #include "Auth.hpp"
 #include <Common.hpp>
@@ -429,18 +426,6 @@ void FileServerRequestHandler::handleRequest(const 
HTTPRequest& request, Poco::M
         sendError(404, request, socket, "404 - file not found!",
                   "There seems to be a problem locating");
     }
-    catch (const boost::exception&  exc)
-    {
-        LOG_WRN("FileServerRequestHandler: " << 
boost::diagnostic_information(exc));
-        sendError(404, request, socket, "404 - file not found!",
-            "There seems to be a localization problem");
-    }
-    catch (const std::exception&  exc)
-    {
-        LOG_WRN("FileServerRequestHandler: " << exc.what());
-        sendError(404, request, socket, "404 - file not found!",
-            "Internal error");
-    }
 }
 
 void FileServerRequestHandler::sendError(int errorCode, const 
Poco::Net::HTTPRequest& request,
@@ -698,19 +683,11 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
         documentSigningDiv = "<div id=\"document-signing-bar\"></div>";
     }
 
-    std::string lang("en");
+    std::string lang;
+    std::locale locale;
     std::ostringstream ostr;
     std::istringstream istr(preprocess);
 
-    auto pos = std::find_if(params.begin(), params.end(),
-        [](const std::pair<std::string, std::string>& it) { return it.first == 
"lang"; });
-    if (pos != params.end())
-    {
-        lang = pos->second;
-    }
-
-    std::locale locale(LOOLWSD::Generator(lang + ".utf8"));
-
     parse(locale, istr, ostr, [&](const std::string& var) {
         bool result = true;
         if (var == "ACCESS_TOKEN")
@@ -1000,7 +977,8 @@ void FileServerRequestHandler::parse(const std::locale& 
locale, std::istringstre
         {
             if (state == ParseState::L10n)
             {
-                ostr << '\'' << boost::locale::gettext(varL10n.str().c_str(), 
locale) << '\'';
+                LOG_INF(locale.name());
+                //ostr << '\'' << 
boost::locale::gettext(varL10n.str().c_str(), locale) << '\'';
                 state = ParseState::None;
             }
             else ostr << token;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b3f1bfaf3..2093211f7 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -694,7 +694,6 @@ unsigned LOOLWSD::MaxConnections;
 unsigned LOOLWSD::MaxDocuments;
 std::string LOOLWSD::OverrideWatermark;
 std::set<const Poco::Util::AbstractConfiguration*> 
LOOLWSD::PluginConfigurations;
-boost::locale::generator LOOLWSD::Generator;
 
 static std::string UnitTestLibrary;
 
@@ -1013,12 +1012,6 @@ void LOOLWSD::initialize(Application& self)
     ChildRoot = getPathFromConfig("child_root_path");
     ServerName = config().getString("server_name");
 
-    Generator.locale_cache_enabled(true);
-    Generator.add_messages_domain("loolwsd");
-    Generator.characters(boost::locale::char_facet);
-    Generator.categories(boost::locale::message_facet);
-    Generator.add_messages_path(config().getString("application.dir", "./") + 
"locale");
-
     FileServerRoot = getPathFromConfig("file_server_root_path");
     NumPreSpawnedChildren = getConfigValue<int>(conf, "num_prespawn_children", 
1);
     if (NumPreSpawnedChildren < 1)
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 73571c9f0..f4c2db405 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -21,7 +21,6 @@
 #include <Poco/Util/AbstractConfiguration.h>
 #include <Poco/Util/OptionSet.h>
 #include <Poco/Util/ServerApplication.h>
-#include <boost/locale.hpp>
 
 #include "Util.hpp"
 
@@ -73,7 +72,6 @@ public:
     static unsigned MaxDocuments;
     static std::string OverrideWatermark;
     static std::set<const Poco::Util::AbstractConfiguration*> 
PluginConfigurations;
-    static boost::locale::generator Generator;
 
     static std::vector<int> getKitPids();
 
commit 2383a205c76dfcd38d2cf6dd6f2e93beac73ab7b
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:26:22 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:26:22 2019 +0100

    Revert "wsd: preprocess javascript file for L10n"
    
    This reverts commit 306b12b9bc2e0808751ea24282be792839d9ca40.

diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 97509813d..b82becbf1 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -335,10 +335,7 @@ void FileServerRequestHandler::handleRequest(const 
HTTPRequest& request, Poco::M
             const std::string fileType = endPoint.substr(extPoint + 1);
             std::string mimeType;
             if (fileType == "js")
-            {
-                preprocessJS(request, socket);
-                return;
-            }
+                mimeType = "application/javascript";
             else if (fileType == "css")
                 mimeType = "text/css";
             else if (fileType == "html")
@@ -1050,37 +1047,4 @@ void FileServerRequestHandler::parse(const std::locale& 
locale, std::istringstre
         ostr << varL10n.str();
     }
 }
-
-void FileServerRequestHandler::preprocessJS(const HTTPRequest& request, const 
std::shared_ptr<StreamSocket>& socket)
-{
-    std::string lang("en");
-    Poco::Net::HTTPResponse response;
-    const Poco::URI::QueryParameters params = 
Poco::URI(request.getURI()).getQueryParameters();
-    auto pos = std::find_if(params.begin(), params.end(),
-        [](const std::pair<std::string, std::string>& it) { return it.first == 
"lang"; });
-    if (pos != params.end())
-        lang = pos->second;
-
-    response.setContentType("application/javascript");
-    response.set("User-Agent", HTTP_AGENT_STRING);
-    response.set("Date", Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT));
-    response.add("X-Content-Type-Options", "nosniff");
-
-    const std::string relPath = getRequestPathname(request);
-    LOG_DBG("Preprocessing file: " << relPath);
-    std::string preprocess = *getUncompressedFile(relPath);
-
-    std::ostringstream ostr;
-    std::istringstream istr(preprocess);
-    std::locale locale(LOOLWSD::Generator(lang + ".utf8"));
-
-    parse(locale, istr, ostr, [](const std::string&) { return false; });
-
-    std::ostringstream oss;
-    response.write(oss);
-    oss << ostr.str();
-    socket->send(oss.str());
-
-    LOG_DBG("Sent file: " << relPath);
-}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp
index df33ca217..c5a5133cd 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -22,7 +22,6 @@ class FileServerRequestHandler
 
     static void getToken(std::istringstream&, std::string&);
     static void parse(const std::locale&, std::istringstream&, 
std::ostringstream&, const std::function<bool(const std::string&)>&);
-    static void preprocessJS(const Poco::Net::HTTPRequest& request, const 
std::shared_ptr<StreamSocket>& socket);
     static void preprocessFile(const Poco::Net::HTTPRequest& request, 
Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket);
     static void preprocessAdminFile(const Poco::Net::HTTPRequest& request, 
const std::shared_ptr<StreamSocket>& socket);
 public:
commit b2bd10445d7cf49e1ce1295341cc527d70869302
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:26:12 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:26:12 2019 +0100

    Revert "wsd: allow compression gzip for html and js resources"
    
    This reverts commit b879f9dd06afec3275cb820cdc88e776978790f5.

diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 9626daf76..97509813d 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -24,7 +24,6 @@
 #include <Poco/DateTime.h>
 #include <Poco/DateTimeFormat.h>
 #include <Poco/DateTimeFormatter.h>
-#include <Poco/DeflatingStream.h>
 #include <Poco/Exception.h>
 #include <Poco/FileStream.h>
 #include <Poco/Net/HTMLForm.h>
@@ -702,9 +701,8 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
         documentSigningDiv = "<div id=\"document-signing-bar\"></div>";
     }
 
-    std::streampos size;
     std::string lang("en");
-    std::ostringstream ostr, ogzip;
+    std::ostringstream ostr;
     std::istringstream istr(preprocess);
 
     auto pos = std::find_if(params.begin(), params.end(),
@@ -781,16 +779,6 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
     });
 
     const std::string mimeType = "text/html";
-    bool gzip = request.hasToken("Accept-Encoding", "gzip");
-    if (gzip)
-    {
-        Poco::DeflatingOutputStream deflater(ogzip, 
Poco::DeflatingStreamBuf::STREAM_GZIP, 8);
-        deflater << ostr.str();
-        deflater.close();
-        size = ogzip.tellp();
-    }
-    else
-        size = ostr.tellp();
 
     std::ostringstream oss;
     oss << "HTTP/1.1 200 OK\r\n"
@@ -807,9 +795,6 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
 
     // Document signing: if endpoint URL is configured, whitelist that for
     // iframe purposes.
-    if (gzip)
-        oss << "Content-Encoding: gzip\r\n";
-
     std::ostringstream cspOss;
     cspOss << "Content-Security-Policy: default-src 'none'; "
            << "frame-src 'self' blob: " << documentSigningURL << "; "
@@ -919,7 +904,7 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
     }
 
     oss << "\r\n"
-        << (gzip ? ogzip.str() : ostr.str());
+        << ostr.str();
 
     socket->send(oss.str());
     LOG_DBG("Sent file: " << relPath << ": " << preprocess);
@@ -1076,39 +1061,26 @@ void FileServerRequestHandler::preprocessJS(const 
HTTPRequest& request, const st
     if (pos != params.end())
         lang = pos->second;
 
+    response.setContentType("application/javascript");
+    response.set("User-Agent", HTTP_AGENT_STRING);
+    response.set("Date", Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT));
+    response.add("X-Content-Type-Options", "nosniff");
+
     const std::string relPath = getRequestPathname(request);
     LOG_DBG("Preprocessing file: " << relPath);
     std::string preprocess = *getUncompressedFile(relPath);
 
-    std::streampos size;
-    std::ostringstream oss, ostr, ogzip;
+    std::ostringstream ostr;
     std::istringstream istr(preprocess);
     std::locale locale(LOOLWSD::Generator(lang + ".utf8"));
 
     parse(locale, istr, ostr, [](const std::string&) { return false; });
 
-    bool gzip = request.hasToken("Accept-Encoding", "gzip");
-    if (gzip)
-    {
-        response.set("Content-Encoding", "gzip");
-        Poco::DeflatingOutputStream deflater(ogzip, 
Poco::DeflatingStreamBuf::STREAM_GZIP, 8);
-        deflater << ostr.str();
-        deflater.close();
-        size = ogzip.tellp();
-    }
-    else
-        size = ostr.tellp();
-
-    response.setContentType("application/javascript");
-    response.setContentLength(static_cast<int>(size));
-    response.setChunkedTransferEncoding(false);
-    response.set("User-Agent", HTTP_AGENT_STRING);
-    response.set("Date", Poco::DateTimeFormatter::format(Poco::Timestamp(), 
Poco::DateTimeFormat::HTTP_FORMAT));
-    response.add("X-Content-Type-Options", "nosniff");
+    std::ostringstream oss;
     response.write(oss);
-
-    oss << (gzip ? ogzip.str() : ostr.str());
+    oss << ostr.str();
     socket->send(oss.str());
+
     LOG_DBG("Sent file: " << relPath);
 }
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8ad126820cb4f80613e8960ac21bc1f4fe72e8ce
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:26:03 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Fri Mar 15 17:26:03 2019 +0100

    Revert "ignore generated m4 files"
    
    This reverts commit ad9e0c7c4fa01e05b61b2cb86072002577168095.

diff --git a/.gitignore b/.gitignore
index b6c02e3bd..ab93d7460 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,8 +50,6 @@ cscope*
 loolwsd.log
 *.log.*.gz
 *.lo
-m4/lt*.m4
-m4/libtool.m4
 
 # loleaflet
 loleaflet/dist
commit 47b77f8d60cd6fa8448eb9624efdc15838ed04d6
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Mar 15 17:25:53 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to