Merge pull request #2389 from dibdot/adblock
authorDirk Brenken <dev@brenken.org>
Sat, 22 Dec 2018 17:53:04 +0000 (18:53 +0100)
committerGitHub <noreply@github.com>
Sat, 22 Dec 2018 17:53:04 +0000 (18:53 +0100)
luci-app-adblock: minor fixes

applications/luci-app-uhttpd/luasrc/model/cbi/uhttpd/uhttpd.lua
contrib/package/csstidy/Makefile
libs/luci-lib-jsonc/src/jsonc.c
themes/luci-theme-material/htdocs/luci-static/material/cascade.css

index 883e1bb631b1840c4eb99c21a5ad233e9dcb26ff..eadf9b57226546da8b02efb79037e07fdd86ef79 100644 (file)
@@ -42,7 +42,7 @@ function lhttp.validate(self, value, section)
                end
        end
        if not (have_http_listener or have_https_listener) then
-               return nil, "must listen on at list one address:port"
+               return nil, "must listen on at least one address:port"
        end
        return DynamicList.validate(self, value, section)
 end
@@ -78,7 +78,7 @@ function lhttps.validate(self, value, section)
                end
        end
        if not (have_http_listener or have_https_listener) then
-               return nil, "must listen on at list one address:port"
+               return nil, "must listen on at least one address:port"
        end
        return DynamicList.validate(self, value, section)
 end
index 419d50719a6cb82f662f56aafdcf78923555923d..83f8f080269a3e87886ccf2253d3e6707c48ec93 100644 (file)
@@ -5,9 +5,9 @@ PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=https://github.com/jow-/csstidy-cpp.git
-PKG_SOURCE_DATE:=2018-12-12.1
-PKG_SOURCE_VERSION:=33594b4783cc944da8197b2209c2a47af3aa42a4
-PKG_MIRROR_HASH:=3c9ba0c244e850bb897e08cb1c96d4e861a93a8a26871b5a0d54cf88c60422f5
+PKG_SOURCE_DATE:=2018-12-20
+PKG_SOURCE_VERSION:=1d5620149ae35c0d49fb2014d4e63a23ecfb6f69
+PKG_MIRROR_HASH:=3210d475f6ae966d4dfcd3e1f7fcbf0ad9507a37878d50de015ffe795c1d160e
 
 PKG_LICENSE:=LGPL-2.1
 PKG_LICENSE_FILES:=COPYING
index ef1110166055a78bf32cf1a6fbbd3e356b2bce3f..9ff8520dbc43a2c7958b0882395ef15997254f33 100644 (file)
@@ -27,6 +27,12 @@ limitations under the License.
 #define LUCI_JSONC "luci.jsonc"
 #define LUCI_JSONC_PARSER "luci.jsonc.parser"
 
+struct seen {
+       size_t size;
+       size_t len;
+       const void *ptrs[];
+};
+
 struct json_state {
        struct json_object *obj;
        struct json_tokener *tok;
@@ -35,6 +41,7 @@ struct json_state {
 
 static void _json_to_lua(lua_State *L, struct json_object *obj);
 static struct json_object * _lua_to_json(lua_State *L, int index);
+static struct json_object * _lua_to_json_rec(lua_State *L, int index, struct seen **seen);
 
 static int json_new(lua_State *L)
 {
@@ -199,6 +206,9 @@ static int _lua_test_array(lua_State *L, int index)
        int max = 0;
        lua_Number idx;
 
+       if (!lua_checkstack(L, 2))
+               return -1;
+
        lua_pushnil(L);
 
        /* check for non-integer keys */
@@ -243,16 +253,54 @@ out:
        return max;
 }
 
-static struct json_object * _lua_to_json(lua_State *L, int index)
+
+static bool visited(struct seen **sp, const void *ptr) {
+       struct seen *s = *sp;
+       size_t i;
+
+       if (s->len >= s->size)
+       {
+               i = s->size + 10;
+               s = realloc(*sp, sizeof(struct seen) + sizeof(void *) * i);
+
+               if (!s)
+               {
+                       if (*sp)
+                               free(*sp);
+
+                       *sp = NULL;
+                       return true;
+               }
+
+               s->size = i;
+               *sp = s;
+       }
+
+       for (i = 0; i < s->len; i++)
+               if (s->ptrs[i] == ptr)
+                       return true;
+
+       s->ptrs[s->len++] = ptr;
+       return false;
+}
+
+static struct json_object * _lua_to_json_rec(lua_State *L, int index,
+                                             struct seen **seen)
 {
        lua_Number nd, ni;
        struct json_object *obj;
        const char *key;
        int i, max;
 
+       if (index < 0)
+               index = lua_gettop(L) + index + 1;
+
        switch (lua_type(L, index))
        {
        case LUA_TTABLE:
+               if (visited(seen, lua_topointer(L, index)))
+                       return NULL;
+
                max = _lua_test_array(L, index);
 
                if (max >= 0)
@@ -262,12 +310,15 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
                        if (!obj)
                                return NULL;
 
+                       if (!lua_checkstack(L, 1))
+                               return NULL;
+
                        for (i = 1; i <= max; i++)
                        {
                                lua_rawgeti(L, index, i);
 
                                json_object_array_put_idx(obj, i - 1,
-                                                         _lua_to_json(L, lua_gettop(L)));
+                                                         _lua_to_json_rec(L, -1, seen));
 
                                lua_pop(L, 1);
                        }
@@ -280,6 +331,9 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
                if (!obj)
                        return NULL;
 
+               if (!lua_checkstack(L, 3))
+                       return NULL;
+
                lua_pushnil(L);
 
                while (lua_next(L, index))
@@ -289,7 +343,7 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
 
                        if (key)
                                json_object_object_add(obj, key,
-                                                      _lua_to_json(L, lua_gettop(L) - 1));
+                                                      _lua_to_json_rec(L, -2, seen));
 
                        lua_pop(L, 2);
                }
@@ -318,6 +372,23 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
        return NULL;
 }
 
+static struct json_object * _lua_to_json(lua_State *L, int index)
+{
+       struct seen *s = calloc(sizeof(struct seen) + sizeof(void *) * 10, 1);
+       struct json_object *rv;
+
+       if (!s)
+               return NULL;
+
+       s->size = 10;
+
+       rv = _lua_to_json_rec(L, index, &s);
+
+       free(s);
+
+       return rv;
+}
+
 static int json_parse_set(lua_State *L)
 {
        struct json_state *s = luaL_checkudata(L, 1, LUCI_JSONC_PARSER);
index dc569113664d88d4ed35cf2792eeb4a6d102933c..8c6f6811056a05926f3e5c9232e5ab902fff3510 100644 (file)
@@ -571,7 +571,7 @@ header > .fill > .container > .status > * {
        display: block;
        padding: .5rem 1rem;
        text-decoration: none;
-       color: #202124;
+       color: var(--menu-color);
 }
 
 .main > .main-left > .nav > li:hover,