summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base')
-rw-r--r--modules/luci-base/luasrc/dispatcher.lua15
-rw-r--r--modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua6
-rw-r--r--modules/luci-base/luasrc/view/error404.htm2
-rw-r--r--modules/luci-base/po/ca/base.po6
-rw-r--r--modules/luci-base/po/cs/base.po6
-rw-r--r--modules/luci-base/po/de/base.po6
-rw-r--r--modules/luci-base/po/el/base.po6
-rw-r--r--modules/luci-base/po/en/base.po6
-rw-r--r--modules/luci-base/po/es/base.po6
-rw-r--r--modules/luci-base/po/fr/base.po6
-rw-r--r--modules/luci-base/po/he/base.po6
-rw-r--r--modules/luci-base/po/hu/base.po6
-rw-r--r--modules/luci-base/po/it/base.po6
-rw-r--r--modules/luci-base/po/ja/base.po6
-rw-r--r--modules/luci-base/po/ko/base.po6
-rw-r--r--modules/luci-base/po/ms/base.po6
-rw-r--r--modules/luci-base/po/no/base.po6
-rw-r--r--modules/luci-base/po/pl/base.po6
-rw-r--r--modules/luci-base/po/pt-br/base.po6
-rw-r--r--modules/luci-base/po/pt/base.po6
-rw-r--r--modules/luci-base/po/ro/base.po6
-rw-r--r--modules/luci-base/po/ru/base.po6
-rw-r--r--modules/luci-base/po/sk/base.po6
-rw-r--r--modules/luci-base/po/sv/base.po6
-rw-r--r--modules/luci-base/po/templates/base.pot6
-rw-r--r--modules/luci-base/po/tr/base.po6
-rw-r--r--modules/luci-base/po/uk/base.po6
-rw-r--r--modules/luci-base/po/vi/base.po6
-rw-r--r--modules/luci-base/po/zh-cn/base.po9
-rw-r--r--modules/luci-base/po/zh-tw/base.po6
-rw-r--r--modules/luci-base/src/template_lualib.c49
-rw-r--r--modules/luci-base/src/template_utils.c124
-rw-r--r--modules/luci-base/src/template_utils.h6
33 files changed, 354 insertions, 13 deletions
diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
index 4866727572..5fc2b80e71 100644
--- a/modules/luci-base/luasrc/dispatcher.lua
+++ b/modules/luci-base/luasrc/dispatcher.lua
@@ -75,11 +75,16 @@ function error404(message)
http.status(404, "Not Found")
message = message or "Not Found"
- require("luci.template")
- if not util.copcall(luci.template.render, "error404") then
+ local function render()
+ local template = require "luci.template"
+ template.render("error404")
+ end
+
+ if not util.copcall(render) then
http.prepare_content("text/plain")
http.write(message)
end
+
return false
end
@@ -113,7 +118,8 @@ function httpdispatch(request, prefix)
end
end
- for node in pathinfo:gmatch("[^/]+") do
+ local node
+ for node in pathinfo:gmatch("[^/%z]+") do
r[#r+1] = node
end
@@ -136,8 +142,7 @@ local function require_post_security(target)
if (type(required_val) == "string" and
request_val ~= required_val) or
- (required_val == true and
- (request_val == nil or request_val == ""))
+ (required_val == true and request_val == nil)
then
return false
end
diff --git a/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua b/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua
index 6668dad839..47cb901a5b 100644
--- a/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua
+++ b/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua
@@ -202,7 +202,7 @@ TZ = {
{ 'America/Winnipeg', 'CST6CDT,M3.2.0,M11.1.0' },
{ 'America/Yakutat', 'AKST9AKDT,M3.2.0,M11.1.0' },
{ 'America/Yellowknife', 'MST7MDT,M3.2.0,M11.1.0' },
- { 'Antarctica/Casey', '<+11>-11' },
+ { 'Antarctica/Casey', '<+08>-8' },
{ 'Antarctica/Davis', '<+07>-7' },
{ 'Antarctica/DumontDUrville', '<+10>-10' },
{ 'Antarctica/Macquarie', '<+11>-11' },
@@ -239,8 +239,8 @@ TZ = {
{ 'Asia/Dubai', '<+04>-4' },
{ 'Asia/Dushanbe', '<+05>-5' },
{ 'Asia/Famagusta', 'EET-2EEST,M3.5.0/3,M10.5.0/4' },
- { 'Asia/Gaza', 'EET-2EEST,M3.5.6/1,M10.5.6/1' },
- { 'Asia/Hebron', 'EET-2EEST,M3.5.6/1,M10.5.6/1' },
+ { 'Asia/Gaza', 'EET-2EEST,M3.4.6/1,M10.5.6/1' },
+ { 'Asia/Hebron', 'EET-2EEST,M3.4.6/1,M10.5.6/1' },
{ 'Asia/Ho Chi Minh', '<+07>-7' },
{ 'Asia/Hong Kong', 'HKT-8' },
{ 'Asia/Hovd', '<+07>-7' },
diff --git a/modules/luci-base/luasrc/view/error404.htm b/modules/luci-base/luasrc/view/error404.htm
index bc74226830..a762f6038b 100644
--- a/modules/luci-base/luasrc/view/error404.htm
+++ b/modules/luci-base/luasrc/view/error404.htm
@@ -7,5 +7,5 @@
<%+header%>
<h2 name="content">404 <%:Not Found%></h2>
<p><%:Sorry, the object you requested was not found.%></p>
-<tt><%:Unable to dispatch%>: <%=luci.http.request.env.PATH_INFO%></tt>
+<tt><%:Unable to dispatch%>: <%=url(unpack(luci.dispatcher.context.request))%></tt>
<%+footer%>
diff --git a/modules/luci-base/po/ca/base.po b/modules/luci-base/po/ca/base.po
index 0db5d300cf..c413b7172d 100644
--- a/modules/luci-base/po/ca/base.po
+++ b/modules/luci-base/po/ca/base.po
@@ -2159,6 +2159,9 @@ msgstr "Avís"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "D'acord"
@@ -2918,6 +2921,9 @@ msgstr "Mida"
msgid "Size (.ipk)"
msgstr "Mida (.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Salta"
diff --git a/modules/luci-base/po/cs/base.po b/modules/luci-base/po/cs/base.po
index 53c714a16f..89714cc818 100644
--- a/modules/luci-base/po/cs/base.po
+++ b/modules/luci-base/po/cs/base.po
@@ -2167,6 +2167,9 @@ msgstr "Oznámení"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2944,6 +2947,9 @@ msgstr "Velikost"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Přeskočit"
diff --git a/modules/luci-base/po/de/base.po b/modules/luci-base/po/de/base.po
index 7b8ac4c290..fd495b9507 100644
--- a/modules/luci-base/po/de/base.po
+++ b/modules/luci-base/po/de/base.po
@@ -2233,6 +2233,9 @@ msgstr "Notiz"
msgid "Nslookup"
msgstr "DNS-Auflösung"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -3044,6 +3047,9 @@ msgstr "Größe"
msgid "Size (.ipk)"
msgstr "Größe (.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Überspringen"
diff --git a/modules/luci-base/po/el/base.po b/modules/luci-base/po/el/base.po
index 9e740ede4f..ad5ed07fb9 100644
--- a/modules/luci-base/po/el/base.po
+++ b/modules/luci-base/po/el/base.po
@@ -2175,6 +2175,9 @@ msgstr "Επισήμανση"
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "Εντάξει"
@@ -2936,6 +2939,9 @@ msgstr "Μέγεθος"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Παράκαμψη"
diff --git a/modules/luci-base/po/en/base.po b/modules/luci-base/po/en/base.po
index 190a43f125..f629135950 100644
--- a/modules/luci-base/po/en/base.po
+++ b/modules/luci-base/po/en/base.po
@@ -2142,6 +2142,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2900,6 +2903,9 @@ msgstr "Size"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Skip"
diff --git a/modules/luci-base/po/es/base.po b/modules/luci-base/po/es/base.po
index 7f7efbc2f0..776f7fb15c 100644
--- a/modules/luci-base/po/es/base.po
+++ b/modules/luci-base/po/es/base.po
@@ -2181,6 +2181,9 @@ msgstr "Aviso"
msgid "Nslookup"
msgstr "NSLookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "Aceptar"
@@ -2957,6 +2960,9 @@ msgstr "Tamaño"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Saltar"
diff --git a/modules/luci-base/po/fr/base.po b/modules/luci-base/po/fr/base.po
index 0fc12eaae2..9de1687204 100644
--- a/modules/luci-base/po/fr/base.po
+++ b/modules/luci-base/po/fr/base.po
@@ -2195,6 +2195,9 @@ msgstr "Note"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2971,6 +2974,9 @@ msgstr "Taille"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Passer au suivant"
diff --git a/modules/luci-base/po/he/base.po b/modules/luci-base/po/he/base.po
index 0750481d07..8d5daf3890 100644
--- a/modules/luci-base/po/he/base.po
+++ b/modules/luci-base/po/he/base.po
@@ -2115,6 +2115,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr ""
@@ -2867,6 +2870,9 @@ msgstr ""
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr ""
diff --git a/modules/luci-base/po/hu/base.po b/modules/luci-base/po/hu/base.po
index e55bab6bf2..5e2ea2b176 100644
--- a/modules/luci-base/po/hu/base.po
+++ b/modules/luci-base/po/hu/base.po
@@ -2184,6 +2184,9 @@ msgstr "Megjegyzés"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2962,6 +2965,9 @@ msgstr "Méret"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Ugrás"
diff --git a/modules/luci-base/po/it/base.po b/modules/luci-base/po/it/base.po
index ce4b79be1e..6b55e23e22 100644
--- a/modules/luci-base/po/it/base.po
+++ b/modules/luci-base/po/it/base.po
@@ -2184,6 +2184,9 @@ msgstr "Notifica"
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2946,6 +2949,9 @@ msgstr "Dimensione"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Salta"
diff --git a/modules/luci-base/po/ja/base.po b/modules/luci-base/po/ja/base.po
index d3c29bc419..4f26025a84 100644
--- a/modules/luci-base/po/ja/base.po
+++ b/modules/luci-base/po/ja/base.po
@@ -2183,6 +2183,9 @@ msgstr "注意"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2967,6 +2970,9 @@ msgstr "サイズ"
msgid "Size (.ipk)"
msgstr "サイズ (.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "スキップ"
diff --git a/modules/luci-base/po/ko/base.po b/modules/luci-base/po/ko/base.po
index ae417e7c00..04d3c6a23a 100644
--- a/modules/luci-base/po/ko/base.po
+++ b/modules/luci-base/po/ko/base.po
@@ -2133,6 +2133,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr ""
@@ -2895,6 +2898,9 @@ msgstr "Size"
msgid "Size (.ipk)"
msgstr "크기 (.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr ""
diff --git a/modules/luci-base/po/ms/base.po b/modules/luci-base/po/ms/base.po
index 1f53a0a017..b478bd623b 100644
--- a/modules/luci-base/po/ms/base.po
+++ b/modules/luci-base/po/ms/base.po
@@ -2113,6 +2113,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "Baik"
@@ -2869,6 +2872,9 @@ msgstr "Saiz"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Skip"
diff --git a/modules/luci-base/po/no/base.po b/modules/luci-base/po/no/base.po
index e5002d5f01..502c3b38a8 100644
--- a/modules/luci-base/po/no/base.po
+++ b/modules/luci-base/po/no/base.po
@@ -2158,6 +2158,9 @@ msgstr "Merk"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2935,6 +2938,9 @@ msgstr "Størrelse"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Gå videre"
diff --git a/modules/luci-base/po/pl/base.po b/modules/luci-base/po/pl/base.po
index 9d5ff5b4d1..956e566e91 100644
--- a/modules/luci-base/po/pl/base.po
+++ b/modules/luci-base/po/pl/base.po
@@ -2203,6 +2203,9 @@ msgstr "Spostrzeżenie"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2983,6 +2986,9 @@ msgstr "Rozmiar"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Pomiń"
diff --git a/modules/luci-base/po/pt-br/base.po b/modules/luci-base/po/pt-br/base.po
index 4e9abab9db..9c4901f3d4 100644
--- a/modules/luci-base/po/pt-br/base.po
+++ b/modules/luci-base/po/pt-br/base.po
@@ -2284,6 +2284,9 @@ msgstr "Aviso"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -3089,6 +3092,9 @@ msgstr "Tamanho"
msgid "Size (.ipk)"
msgstr "Tamanho (.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Pular"
diff --git a/modules/luci-base/po/pt/base.po b/modules/luci-base/po/pt/base.po
index a54f5425b1..8f2622c26d 100644
--- a/modules/luci-base/po/pt/base.po
+++ b/modules/luci-base/po/pt/base.po
@@ -2182,6 +2182,9 @@ msgstr "Reparo"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2953,6 +2956,9 @@ msgstr "Tamanho"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Saltar"
diff --git a/modules/luci-base/po/ro/base.po b/modules/luci-base/po/ro/base.po
index e2edecbb2a..86eaa6495d 100644
--- a/modules/luci-base/po/ro/base.po
+++ b/modules/luci-base/po/ro/base.po
@@ -2112,6 +2112,9 @@ msgstr "Notificare"
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2863,6 +2866,9 @@ msgstr "Marime"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr ""
diff --git a/modules/luci-base/po/ru/base.po b/modules/luci-base/po/ru/base.po
index 03b255fe93..4ffb7233c2 100644
--- a/modules/luci-base/po/ru/base.po
+++ b/modules/luci-base/po/ru/base.po
@@ -2240,6 +2240,9 @@ msgstr "Заметка"
msgid "Nslookup"
msgstr "DNS-запрос"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -3048,6 +3051,9 @@ msgstr "Размер"
msgid "Size (.ipk)"
msgstr "Размер (.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Пропустить"
diff --git a/modules/luci-base/po/sk/base.po b/modules/luci-base/po/sk/base.po
index dc5bc91416..a17ac98e20 100644
--- a/modules/luci-base/po/sk/base.po
+++ b/modules/luci-base/po/sk/base.po
@@ -2087,6 +2087,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr ""
@@ -2835,6 +2838,9 @@ msgstr ""
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr ""
diff --git a/modules/luci-base/po/sv/base.po b/modules/luci-base/po/sv/base.po
index d0bdb69450..089546a37d 100644
--- a/modules/luci-base/po/sv/base.po
+++ b/modules/luci-base/po/sv/base.po
@@ -2108,6 +2108,9 @@ msgstr "Avisering"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2858,6 +2861,9 @@ msgstr "Storlek"
msgid "Size (.ipk)"
msgstr "Storlek (.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Hoppa över"
diff --git a/modules/luci-base/po/templates/base.pot b/modules/luci-base/po/templates/base.pot
index 04c33ad9c3..de8b7fb22c 100644
--- a/modules/luci-base/po/templates/base.pot
+++ b/modules/luci-base/po/templates/base.pot
@@ -2080,6 +2080,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr ""
@@ -2828,6 +2831,9 @@ msgstr ""
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr ""
diff --git a/modules/luci-base/po/tr/base.po b/modules/luci-base/po/tr/base.po
index b0854158b4..45f4a7c342 100644
--- a/modules/luci-base/po/tr/base.po
+++ b/modules/luci-base/po/tr/base.po
@@ -2100,6 +2100,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr ""
@@ -2848,6 +2851,9 @@ msgstr ""
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr ""
diff --git a/modules/luci-base/po/uk/base.po b/modules/luci-base/po/uk/base.po
index ba5a4b8566..b1feed3d18 100644
--- a/modules/luci-base/po/uk/base.po
+++ b/modules/luci-base/po/uk/base.po
@@ -2196,6 +2196,9 @@ msgstr "Попередження"
msgid "Nslookup"
msgstr "DNS-запит"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK"
@@ -2978,6 +2981,9 @@ msgstr "Розмір"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "Пропустити"
diff --git a/modules/luci-base/po/vi/base.po b/modules/luci-base/po/vi/base.po
index f2eeb1f882..ecb369e13e 100644
--- a/modules/luci-base/po/vi/base.po
+++ b/modules/luci-base/po/vi/base.po
@@ -2117,6 +2117,9 @@ msgstr ""
msgid "Nslookup"
msgstr ""
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "OK "
@@ -2875,6 +2878,9 @@ msgstr "Dung lượng "
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr ""
diff --git a/modules/luci-base/po/zh-cn/base.po b/modules/luci-base/po/zh-cn/base.po
index b8fc23b690..4c7dd899a0 100644
--- a/modules/luci-base/po/zh-cn/base.po
+++ b/modules/luci-base/po/zh-cn/base.po
@@ -723,7 +723,8 @@ msgstr "自定义软件源"
msgid ""
"Custom files (certificates, scripts) may remain on the system. To prevent "
"this, perform a factory-reset first."
-msgstr "自定义文件(证书、脚本)会保留在系统上。若无需保留,请先执行恢复出厂设置。"
+msgstr ""
+"自定义文件(证书、脚本)会保留在系统上。若无需保留,请先执行恢复出厂设置。"
msgid ""
"Customizes the behaviour of the device <abbr title=\"Light Emitting Diode"
@@ -2132,6 +2133,9 @@ msgstr "注意"
msgid "Nslookup"
msgstr "Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "确认"
@@ -2905,6 +2909,9 @@ msgstr "大小"
msgid "Size (.ipk)"
msgstr "大小(.ipk)"
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "跳过"
diff --git a/modules/luci-base/po/zh-tw/base.po b/modules/luci-base/po/zh-tw/base.po
index e31c01c55c..28a806e839 100644
--- a/modules/luci-base/po/zh-tw/base.po
+++ b/modules/luci-base/po/zh-tw/base.po
@@ -2124,6 +2124,9 @@ msgstr "通知"
msgid "Nslookup"
msgstr "DNS偵錯Nslookup"
+msgid "Number of cached DNS entries (max is 10000, 0 is no caching)"
+msgstr ""
+
msgid "OK"
msgstr "行"
@@ -2888,6 +2891,9 @@ msgstr "大小"
msgid "Size (.ipk)"
msgstr ""
+msgid "Size of DNS query cache"
+msgstr ""
+
msgid "Skip"
msgstr "跳過"
diff --git a/modules/luci-base/src/template_lualib.c b/modules/luci-base/src/template_lualib.c
index d5c8dd6b4c..45e23966e9 100644
--- a/modules/luci-base/src/template_lualib.c
+++ b/modules/luci-base/src/template_lualib.c
@@ -1,7 +1,7 @@
/*
* LuCI Template - Lua binding
*
- * Copyright (C) 2009 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2009-2018 Jo-Philipp Wich <jo@mein.io>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -110,6 +110,51 @@ int template_L_striptags(lua_State *L)
return 0;
}
+int template_L_urlencode(lua_State *L)
+{
+ size_t len = 0;
+ const char *str = luaL_checkstring(L, 1);
+ char *res = urlencode(str, &len);
+
+ if (res != NULL)
+ {
+ lua_pushlstring(L, res, len);
+ free(res);
+
+ return 1;
+ }
+ else if (len == 0)
+ {
+ lua_pushvalue(L, 1);
+ return 1;
+ }
+
+ return 0;
+}
+
+int template_L_urldecode(lua_State *L)
+{
+ size_t len = 0;
+ const char *str = luaL_checkstring(L, 1);
+ int keep_plus = lua_toboolean(L, 2);
+ char *res = urldecode(str, &len, keep_plus == 1);
+
+ if (res != NULL)
+ {
+ lua_pushlstring(L, res, len);
+ free(res);
+
+ return 1;
+ }
+ else if (len == 0)
+ {
+ lua_pushvalue(L, 1);
+ return 1;
+ }
+
+ return 0;
+}
+
static int template_L_load_catalog(lua_State *L) {
const char *lang = luaL_optstring(L, 1, "en");
const char *dir = luaL_optstring(L, 2, NULL);
@@ -165,6 +210,8 @@ static const luaL_reg R[] = {
{ "utf8", template_L_utf8 },
{ "pcdata", template_L_pcdata },
{ "striptags", template_L_striptags },
+ { "urlencode", template_L_urlencode },
+ { "urldecode", template_L_urldecode },
{ "load_catalog", template_L_load_catalog },
{ "close_catalog", template_L_close_catalog },
{ "change_catalog", template_L_change_catalog },
diff --git a/modules/luci-base/src/template_utils.c b/modules/luci-base/src/template_utils.c
index 3979487f12..eefdd17008 100644
--- a/modules/luci-base/src/template_utils.c
+++ b/modules/luci-base/src/template_utils.c
@@ -1,7 +1,7 @@
/*
* LuCI Template - Utility functions
*
- * Copyright (C) 2010 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2010-2018 Jo-Philipp Wich <jo@mein.io>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -428,6 +428,128 @@ char * striptags(const char *s, unsigned int l)
return buf_destroy(buf);
}
+
+static inline bool is_urlencode_char(char c)
+{
+ return !((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') ||
+ (c == '$') || (c == '_') ||
+ (c == '-') || (c == '.') ||
+ (c == '~'));
+}
+
+/*
+ * URL-encode all special characters in given string and return
+ * encoded copy.
+ *
+ * If no encoding was required, returns NULL. If an encoded_len
+ * pointer is passed, it is set to the length of the encoded string.
+ *
+ * Sets encoded_len and returns NULL if memory allocation failed.
+ */
+char *urlencode(const char *s, size_t *encoded_len)
+{
+ size_t i, enc_len;
+ char *enc, *ptr;
+
+ for (i = 0, enc_len = 0; s[i]; i++)
+ if (is_urlencode_char(s[i]))
+ enc_len += 3;
+ else
+ enc_len++;
+
+ if (i != enc_len)
+ {
+ if (encoded_len)
+ *encoded_len = enc_len;
+
+ enc = calloc(1, enc_len + 1);
+
+ if (!enc)
+ return NULL;
+
+ for (i = 0, ptr = enc; s[i]; i++)
+ if (is_urlencode_char(s[i]))
+ ptr += snprintf(ptr, 4, "%%%02x", (unsigned char)s[i]);
+ else
+ *ptr++ = s[i];
+
+ return enc;
+ }
+
+ return NULL;
+}
+
+/*
+ * URL-decode given string and return decoded copy.
+ *
+ * If no decoding was required, returns NULL. If an decoded_len
+ * pointer is passed, it is set to the length of the decoded string.
+ *
+ * When keep_plus is true, skip decoding of plus ("+") signs into
+ * space (0x20) characters.
+ *
+ * Sets decoded_len and returns NULL if memory allocation failed.
+ */
+
+#define hex(x) \
+ (((x) <= '9') ? ((x) - '0') : \
+ (((x) <= 'F') ? ((x) - 'A' + 10) : \
+ ((x) - 'a' + 10)))
+
+char *urldecode(const char *s, size_t *decoded_len, bool keep_plus)
+{
+ bool changed = false;
+ size_t i, dec_len;
+ char *dec, *ptr;
+
+ for (i = 0, dec_len = 0; s[i]; i++, dec_len++)
+ {
+ if (s[i] == '%' && isxdigit(s[i+1]) && isxdigit(s[i+2]))
+ {
+ changed = true;
+ i += 2;
+ }
+ else if (!keep_plus && s[i] == '+')
+ {
+ changed = true;
+ }
+ }
+
+ if (changed)
+ {
+ if (decoded_len)
+ *decoded_len = dec_len;
+
+ dec = calloc(1, dec_len + 1);
+
+ if (!dec)
+ return NULL;
+
+ for (i = 0, ptr = dec; s[i]; i++)
+ {
+ if (s[i] == '%' && isxdigit(s[i+1]) && isxdigit(s[i+2]))
+ {
+ *ptr++ = (char)(16 * hex(s[i+1]) + hex(s[i+2]));
+ i += 2;
+ }
+ else if (!keep_plus && s[i] == '+')
+ {
+ *ptr++ = ' ';
+ }
+ else
+ {
+ *ptr++ = s[i];
+ }
+ }
+
+ return dec;
+ }
+
+ return NULL;
+}
+
void luastr_escape(struct template_buffer *out, const char *s, unsigned int l,
int escape_xml)
{
diff --git a/modules/luci-base/src/template_utils.h b/modules/luci-base/src/template_utils.h
index 32a79f93bc..872ecb072f 100644
--- a/modules/luci-base/src/template_utils.h
+++ b/modules/luci-base/src/template_utils.h
@@ -1,7 +1,7 @@
/*
* LuCI Template - Utility header
*
- * Copyright (C) 2010-2012 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2010-2018 Jo-Philipp Wich <jo@mein.io>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <stdbool.h>
+#include <ctype.h>
/* buffer object */
@@ -42,6 +44,8 @@ char * buf_destroy(struct template_buffer *buf);
char * utf8(const char *s, unsigned int l);
char * pcdata(const char *s, unsigned int l);
char * striptags(const char *s, unsigned int l);
+char * urlencode(const char *s, size_t *encoded_len);
+char * urldecode(const char *s, size_t *decoded_len, bool keep_plus);
void luastr_escape(struct template_buffer *out, const char *s, unsigned int l, int escape_xml);
void luastr_translate(struct template_buffer *out, const char *s, unsigned int l, int escape_xml);