Commit graph

584 commits

Author SHA1 Message Date
Jo-Philipp Wich
524ce90c4e luci-base: resync base translations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-13 14:24:27 +02:00
Jo-Philipp Wich
22e4a2420c luci-base: tweak tblsection markup
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-13 09:37:08 +02:00
Jo-Philipp Wich
85bc16605d luci-base: add icons for alias interfaces
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12 18:10:59 +02:00
Jo-Philipp Wich
94be4881a0 luci-base: add error reporting and basic support for dynamic interfaces
This allows exposing virtual ubus-based network interfaces in LuCI.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12 18:10:10 +02:00
Jo-Philipp Wich
d4e52ca03b luci-base: apply_widget: various fixes
- Fix button styles in failure message
 - Pause XHR polling during apply/rollback sessions
 - Throttle confirm requests to 1 request/second

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12 18:10:10 +02:00
Jo-Philipp Wich
674b090d34 luci-base: xhr.js: use JSON.parse() and pass request duration to callbacks
JSON.parse() is supported on all modern browsers and a far better
solution than the hakish and potentially dangerous eval().

Also calculate the duration of request and pass it as 3rd argument to the
callback function, this makes it easier to calculate request delays or
poll intervals in code using XHR.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12 18:10:10 +02:00
Jo-Philipp Wich
4a083f6d23 luci-base: fix placement of CBI strings
Commit c0de036b3 ("treewide: always include cbi.js") improperly removed the
cbi.js script include from header.htm, leaving behind the string dictionary.

Move the JSON dictionary to the parent <form> element and delete the
leftover </script> element.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09 17:04:10 +02:00
Jo-Philipp Wich
6cda8e6dab luci-base: cbi.js: avoid setting empty cell title attributes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09 11:51:43 +02:00
Jo-Philipp Wich
260d2cc44e luci-base: cbi.js: add NodeList.forEach() polyfill for IE 11
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09 11:51:43 +02:00
Jo-Philipp Wich
c0de036b31 treewide: always include cbi.js
Include cbi.js in the main header template like it is done for xhr.js and
remove the page specific includes.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-09 11:51:43 +02:00
Krystian Kozak
4b8e0f8347 luci-base: update Polish translation
Updated Polish translations.

Signed-off-by: Krystian Kozak <krystian.kozak20@gmail.com>
2018-07-07 14:48:51 +02:00
INAGAKI Hiroshi
057c71a671 luci-base: update Japanese translation
Updated Japanese translations.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-07-07 17:57:24 +09:00
Yurii
26d90f0c10 luci-base: update Ukrainian translation
Updated with the latest synchronization of the translation, corrections and additions translation.

Signed-off-by: Yurii yuripet@gmail.com
Squashed 2 commits
Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-07-04 21:23:56 +03:00
amitabha
84f86ad7b4 base.po: Update chinese translations.
Fix some Chinese translations.
Signed-off-by: Angus Ding <angus.ding@gmail.com>
2018-07-05 01:29:35 +08:00
Jo-Philipp Wich
04bec56956 luci-base: resync translations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-03 18:47:54 +02:00
Hannu Nyman
1510111fa0
Merge pull request #1925 from YuriPet/master
luci-app-firewall & luci-base: update Ukrainian translation
2018-07-02 18:35:04 +03:00
Jo-Philipp Wich
3aba615029 luci-base: rework "in request" flagging logic for menu nodes
The previous implementation failed to mark active nodes under some
circumstances.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-02 08:46:26 +02:00
Yurii
d0298e4cda
luci-base: update Ukrainian translation
Updated with the latest synchronization of the translation.

Signed-off-by: Yurii yuripet@gmail.com
2018-07-01 23:51:38 +03:00
INAGAKI Hiroshi
ca0a086a2d i18n: sync translations
Synchronized translations with sources.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-06-30 23:10:45 +09:00
Jo-Philipp Wich
c61c5deac4 luci-base: luci.tools.status: add host_hints to DHCPv6 leases
Attempt to derive a MAC from the DHCPv6 lease DUID and use it to look up
a host hint. If a hint is found, add it to the lease information.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-28 09:42:17 +02:00
Jo-Philipp Wich
ccbb17d260
Merge pull request #1915 from Ansuel/upgrade
luci-base: update luasrcdiet
2018-06-27 16:43:36 +02:00
Ansuel Smith
b5d5e5bf13
luci-base: update luasrcdiet
Tested and works with no problem.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2018-06-27 16:41:02 +02:00
Jo-Philipp Wich
002c4d1d5f luci-base: add "Name" label to autogenerated title column
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-25 11:12:25 +02:00
Jo-Philipp Wich
18d92aca53 luci-base: annotate tblsection description row as well
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-25 09:51:18 +02:00
Jo-Philipp Wich
e5ba594d77 luci-base, luci-mod-admin-full: unify wifi assoclist code
Merge the assoclist code of the status overview and wireless overview pages
into a single shared partial template.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-25 09:01:33 +02:00
Jo-Philipp Wich
d0b91bcca2 luci-base: globally cleanup markup
- add responsive attributes to partial cbi templates
 - unify and fix button style classes
 - fix styling of sysauth dialog
 - rework firewall_zoneforwards widget

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-23 17:13:22 +02:00
Jo-Philipp Wich
c4bd6fb7b9 luci-base: cbi.js: add tooltip handling and responsive table helper code
- make findParent() globally available
 - add code for initializing rich cbi tooltips
 - introduce cbi_update_table() helper to auto-assign responsive attributes
   to table markup

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-22 15:14:40 +02:00
Jo-Philipp Wich
69782ccbcc luci-base: xhr.js: defer starting poll queue
Defer the start of the queue poll loop until the document has been loaded.

This allows all XHR.poll() invocations on the page to register their
handlers before the first batch of requests is made.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-22 09:42:15 +02:00
Yurii
fef02b31e6
luci-base: update Ukrainian translation 2018-06-17 23:38:38 +03:00
INAGAKI Hiroshi
fe591dd1cc i18n: fix syntax errors in Ukrainian po
"Content-Type: text/plain; charset=UTF-8" was wrote twice in each
of base.po and firewall.po, and one was an incorrect place which
was the cause of the errors.

And, The escape in abbr HTML tag was incorrect, so I fixed it.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-06-16 23:36:18 +09:00
Kevin Darbyshire-Bryant
8f67019713 wireguard: update wireguard url
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
2018-06-11 11:43:39 +01:00
Yurii
0c410c848b
luci-base: update Ukrainian translation
Updated Polish translations.

Signed-off-by: Yurii <yuripet@gmail.com>
2018-06-10 16:56:13 +03:00
Krystian Kozak
ad5f768c40 luci-base: update Polish translation
Updated Polish translations.

Signed-off-by: Krystian Kozak <krystian.kozak20@gmail.com>
2018-06-10 11:25:54 +02:00
Hannu Nyman
fad02ac8d7
Merge pull request #1868 from sotux/master-zh_CN
Update Simplified Chinese translation
2018-06-09 17:53:27 +03:00
Jo-Philipp Wich
e7866c7dcc luci-mod-admin-full: add suggested italian translations
Merge two italian translations suggested in #1870 and add back two missing
dots accidentially removed from the translations in a previous commit.

Fixes: 588c8618b ("luci-mod-admin-full: fix translation interpolation in JS confirm() calls")
Suggested-by: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08 16:05:48 +02:00
Jo-Philipp Wich
0e0ee2fed5 luci-mod-admin-full: git rid of embedded newlines in translation strings
Also switch one usage of raw '<%_ ... %>' interpolation to '<%: ... %>' in
order to avoid issues with translations using apostrophes.

Globally resnyc translations after the fix.

Fixes #1866.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08 13:50:14 +02:00
Zheng Qian
2e7fa89e1a luci-base: update Simplified Chinese translation
Signed-off-by: Zheng Qian <sotux82@gmail.com>
2018-06-08 16:43:40 +08:00
Jo-Philipp Wich
74be6f3974 treewide: switch firewall zone, network and iface lists to dropdown code
Also switch the weekday and monthday lists in the firewall rule details to
cbi dropdowns, vastly uncluttering the form.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08 08:19:20 +02:00
Jo-Philipp Wich
9d48490729 luci-base: add markup, JS and CSS for new dropdown
This commit introduces the required code for a new, markup based dropdown
widget which can be used as a styleable alternative to select boxes or
radio/checkbox button groups.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08 08:14:36 +02:00
Jo-Philipp Wich
4cca96ef09 luci-base: support option aliases in luci.cbi
AbstractValue descendants may now specify a new optional property `alias`
which refers to a uci option to read/write/remove that differs from the
option name itself.

This is mainly useful for widgets that are toggled based on dependencies,
e.g. for alternating between SingleValue and MultiValue, but which are
intented to write into the same uci option.

Such a setup was previously possible already by overriding the .cfgvalue(),
.write() and .remove() callbacks with custom implementations, but that
required a lot of boiler plate code and was rather fragile.

With the `alias` property, CBI now takes care of the details and tracks
aliased fields within a section accordingly.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-08 07:25:54 +02:00
Jo-Philipp Wich
7be3f0400c luci-base: fix some minor luci.model.uci issues
- Properly serialize option delete changelogs
 - Do not perform a section create if a nil value is passed to set()

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-06 21:45:49 +02:00
Jo-Philipp Wich
2d352a9251 luci-base: cbi: atomically reorder uci sections
Since the switch to ubus uci operations we do not have a local application-
side cursor cache anymore, instead uci operations happen synchronously in
the rpcd backend server.

This may cause cbi section reorder operations involving multiple elements
to fail, because anonymous section hashes may change due to rehashing
between consecutive ubus uci reorder calls.

In order to avoid that problem, use the ubus uci batch reorder extension,
which allows to pass a complete (or partial) list of section ids in the
desired order in one call, bypassing the volatile section id problem.

Fixes #1844.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-03 20:02:44 +02:00
INAGAKI Hiroshi
f28784b61e luci-base: update Japanese translation
Updated Japanese translations.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-06-01 02:45:53 +09:00
INAGAKI Hiroshi
2d196614f4 luci-base: sync translations
Synchronized translations with sources.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-06-01 02:20:05 +09:00
Jo-Philipp Wich
29b391d7bc luci-base: use common alert message markup
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-31 19:06:48 +02:00
Jo-Philipp Wich
298d164dd7 luci-base: update coxpcall() implementation, fix runtime error reporting
Sync our coxpcall() implementation to the newest upstream version in order to
get access to the inner backtrace information and propagate these traces to
the browser in luci.dispatcher.dispatch().

This should make tracking down runtime errors much easier.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-31 17:45:49 +02:00
Jo-Philipp Wich
5427395649 luci-base: add full page overlay during apply
After applying uci configuration, a full map reload is required in many
cases as the anonymous section identifiers might have been rehashed, causing
the rendered map to go out of sync.

To avoid that, add both a full page overlay preventing further page
interaction and let the apply widget forcibly reload the current view once
the operation is complete.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-31 15:38:42 +02:00
Jo-Philipp Wich
c3da1fc232 luci-base: cbi.js: remove unused serialize functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-30 16:04:07 +02:00
Jo-Philipp Wich
d1df5a6b7d luci-base: cbi.js: fix cbi_row_swap() after recent table markup changes
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-30 15:59:52 +02:00
Jo-Philipp Wich
067d7dc9f7 treewide: convert HTML tables to div
Mostly convert HTML tables to div based markup to allow for easier styling
in the future. Also change JS accessor code accordingly.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-28 15:18:45 +02:00
Jo-Philipp Wich
79c82237e3 luci-base: add element creation helper to cbi.js
Add a new helper function `E()` to cbi.js which can be used to conveniently
build HTML markup.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-28 15:18:45 +02:00
Hannu Nyman
6f630b5e66
Merge pull request #1834 from Ansuel/fixpo
luci-base: fix broken translation
2018-05-27 22:07:52 +03:00
Ansuel Smith
c29ffe4dfc
luci-base: fix broken translation
Currently this translation refer to an old string, sync to the new one.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2018-05-27 21:01:33 +02:00
Yusuf Soyipek
2d053d39d0
Update base.po
Some of the shortcomings in Turkish were added.
2018-05-27 16:17:15 +03:00
Hannu Nyman
9de9a71a9f i18n: one more fix for Polish translation
Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-05-25 17:11:47 +03:00
Hannu Nyman
36654b7f4d i18n: sync, fix and cleanup translations
* sync translations (aiccu removal)
* remove some other old strings
* fix Polish translation

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-05-25 16:44:50 +03:00
Ansuel Smith
da1e655294
luci-base: fix dispacher fail
http.getenv("SCRIPT_NAME") fail if it's not provided. This can happen in the login screen when we don't have any script to load.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2018-05-23 02:52:08 +02:00
INAGAKI Hiroshi
b01471b1fc luci-base: update Japanese translation
Updated Japanese translations.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-05-21 01:04:53 +09:00
INAGAKI Hiroshi
b1fd056fa5 i18n: sync translations
Synchronized translations with sources.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-05-21 01:04:53 +09:00
Jo-Philipp Wich
64da34b13c luci-base: handle potential crash in luci.model.network.interface.get_i18n()
Should prevent the crash mentioned in #1779.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-19 22:11:08 +02:00
Jo-Philipp Wich
9ed48ef2a6 luci-base: break circular luci.config <> luci.model.uci dependency
On certain environments, mainly with the embedded uhttpd interpreter, the
luci.config class cannot be loaded due to a circular dependency with the
luci.model.uci class.

Break up the dependency by deferring the loading of luci.config in
luci.model.uci until it is actually needed.

Fixes #1803, FS#1553.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-19 13:07:37 +02:00
Jo-Philipp Wich
828202ef52
Merge pull request #1769 from jow-/master
UCI apply/rollback workflow
2018-05-18 16:44:33 +02:00
Jo-Philipp Wich
80cb4fef8c luci-base: raise maximum POST value size to 100KB
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-18 16:43:29 +02:00
Hannu Nyman
521554f4a7
Merge pull request #1748 from hnyman/wifidata
luci-base: show wifi chip identification on overview
2018-05-18 12:51:24 +03:00
Rixerx
3782e74cf8 luci-base: update Polish translation
Signed-off-by: Rixerx <krystian.kozak20@gmail.com>
2018-05-15 11:40:27 +02:00
Yousong Zhou
2f0f456b71 luci-base: harden cookie sysauth=
A simple scan of the code indicates that currently no code in the repo
is accessing the sysauth= cookie

Closes openwrt/luci#1555

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2018-05-13 18:30:47 +08:00
Florian Eckert
6f3007980b luci-base: reload log on uci system change
If log configuration get changed in uci system no new values are applied
until reboot. Add /etc/init.d/log reload to exec option will solve this
issue.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-05-07 14:37:35 +08:00
Florian Eckert
3cb7452eba luci-base: fix i18n de typo for rc.local
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-05-07 13:51:18 +08:00
Jo-Philipp Wich
9f796fad3a luci-base: add transitional /etc/init.d/ucitrack
Ship an /etc/init.d/ucitrack for spawning a virtual service with the sole
purpose to track the configurations and dependencies formerly handled by
luci-reload.

Once all LuCI supported services ship with procd compatible init scripts,
the uci track support can be dropped.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05 23:11:23 +02:00
Jo-Philipp Wich
8deb949551 treewide: rework uci apply workflow
Switch to rpcd based uci apply/rollback workflow which helps to avoid soft-
bricking devices by requiring an explicit confirmation call after config
apply.

When a user now clicks "Save & Apply", LuCI first issues a call to uci apply
which commits and reloads configuration, then goes into a polling countdown
mode where it repeatedly attempts to call uci confirm.

If the committed configuration is sane, the confirm call will go through and
cancel rpcd's pending rollback timer.

If the configuration change leads to a loss of connectivity (e.g. due to bad
firewall rules or similar), the rollback mechanism will kick in after the
timeout and revert configuration files and pending changes to the pre-apply
state.

In order to cover such rare cases where a lost of connectivity is expected
and desired, the user is offered an "unchecked" apply option after timing
out, which allows committing and applying the changes anyway, without the
extra safety checks.

As a consequence of this change, the luci-reload mechanism is now completely
unsused since rpcd uses ubus config reload signals to reload affected
services, which means that only procd-enabled services will receive proper
reload treatment with the new workflow.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05 23:11:23 +02:00
Jo-Philipp Wich
7cca313959 luci-base: enable uci session isolation
Switch to per-session save directories to decouple LuCI configuration changes
from system wide ones.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05 23:11:23 +02:00
Jo-Philipp Wich
34821b15a5 luci-base: xhr.js: fix timeout setting with IE 11
Internet Explorer 11 requires the timeout to be applied after the open()
call, otherwise an invlaid state exception will be raised

Fixes aa6c97154 ("luci-base: extend xhr.js")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05 21:16:53 +02:00
Hannu Nyman
4edc9256fa luci-base: show wifi chip identification on overview
Show the correct wifi chip identification in case iwinfo
recognises the chip.

So far the wifidev.get_i18n function has practically always
returned just "Generic", but use iwinfo.hardware_name to
fetch the name.

In case iwinfo returns the default "Generic MAC80211", there
is a double 80211 in the final string, which is a cosmetic bug.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-05-05 21:20:41 +03:00
Jo-Philipp Wich
b0f3946570 luci-base: support hiding the "Back to Overview" button in cbi maps
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-03 08:25:26 +02:00
Jo-Philipp Wich
07de9190d8 Revert "luci-base: support hiding the "Back to Overview" button in cbi maps"
This reverts commit 52cf265c9d.

I accidentally committed unrelated changes.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-03 08:24:36 +02:00
Jo-Philipp Wich
52cf265c9d luci-base: support hiding the "Back to Overview" button in cbi maps
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-03 08:22:55 +02:00
Ricardo Lamego
e55a5fa386 Fixing small typo
indentifies > identifies
2018-05-02 21:01:53 +01:00
INAGAKI Hiroshi
27af493779 luci-base: update Japanese translation
Updated Japanese translations.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-05-03 00:25:41 +09:00
INAGAKI Hiroshi
0efc6daecf luci-base: sync translations
Synchronized translations with sources.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-05-02 23:53:48 +09:00
Jo-Philipp Wich
aa6c97154e luci-base: extend xhr.js
Add timeout options to get() and post() and introduce XHR.stop() to support
stopping a poll operation.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-26 09:40:17 +02:00
Jo-Philipp Wich
8459ec0ec8 luci-base: add simple CORS handling to luci.dispatcher
Support a new boolean property `cors` which - if set to true - causes the
dispatcher to positively answer CORS OPTIONS requests after authentication
without actually running the dispatching target.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-26 08:26:30 +02:00
Jo-Philipp Wich
7d13ec6010 luci-base: handle bodies of non-POST requests as well
Decode the HTTP message bodies of any request carrying a Content-Length
header, not just those in POST requests.

This allows handling parameters in other methods, OPTIONS in particular.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-26 08:26:19 +02:00
INAGAKI Hiroshi
f55a1faeaa luci-base: update japanese translation
Updated japanese translations.

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-04-26 00:30:23 +09:00
Jo-Philipp Wich
11f4a50b3f luci-base: additionally return error code strings in luci.util.ubus()
Add a 3rd return value to luci.util.ubus() containing the string value
of the error return value.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-24 19:22:55 +02:00
Jo-Philipp Wich
914c661b58 luci-base: ensure that file upload values have length
Ensure that the (table) length of a file upload value has nonzero length
by initializing the first table index with the file name.

This fixes tests in the form

    x = luci.http.formvalue(...)
    if x and #x > 0 then ... end

Fixes #1763.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-24 13:44:40 +02:00
Jo-Philipp Wich
82abf9add9 luci-base: decode plus signs in x-www-form-urlencoded POST data
Depends on 5ef51b2ab ("lucihttp: update to latest HEAD").
Fixes #1755.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-22 12:03:23 +02:00
Jo-Philipp Wich
628048772d luci-base: ship rpcd uci access ACL
Ship an ACL definition for granting full read/write access to uci
configuration files via ubus rpc. This is a precondition for enabling
uci session isolation later on.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-21 14:59:41 +02:00
Jo-Philipp Wich
172155eb46 luci-base: properly handle repeated POST parameters
Restore the old luci.http behaviour of converting repeated POST params into
single tables holding all values instead of letting each repeated parameter
overwrite the value of the preceeding one.

Fixes, among other things, the handling of CBI dynamic list values.

Fixes #1752
Fixes 59dea0230 ("luci-base: switch to lucihttp based POST data processing")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-19 12:00:13 +02:00
Jo-Philipp Wich
9b22c9c1e1 luci-base: implement session handling in luci.model.uci
Introduce luci.model.uci.set_session_id() and luci.model.uci.get_session_id()
to set and get the effective session ID respectively.

When a session ID is set, it is sent as `ubus_rpc_session` attribute to rpcd,
causing it to use per-session change directories, isolating LuCI changes from
the global system uci state.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-19 11:42:12 +02:00
Jo-Philipp Wich
fc8f825e2f luci-base: drop dependency on libuci-lua
LuCI itself now uses ubus calls to interact with uci configuration while
the remaining direct libuci-lua users have been updated to either depend
on the binding library or to use luci.model.uci.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:54:53 +02:00
Jo-Philipp Wich
b4040aacb0 libs: move http.protocol.{date,mime,conditionals} to luci-lib-httpprotoutils
Also adjust the dependencies of components depending on these classes and
flatten the namespace from luci.http.protocol.* to luci.http.*

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
eb4571c6dc luci-base: fold luci.http.protocol into luci.http
With only the decoder routines remaining in luci.http.protocol, it makes no
sense to keep the low level protocol class around, so fold the remaining code
into the central luci.http class.

Also adjust the few direct users of luci.http.protocol accordingly.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
8f66de12c1 luci-base: refactor luci.http
- Rewrite getcookie() to use liblucihttp header value parsing
 - Rewrite setfilehandler() to use local variables and have cleaner code
 - Fix build_querystring() to actually *en*code the given params

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
db0d5b33d0 luci-base: drop luci.util.dtable()
The dtable() function has no user in the entire LuCI repo, so drop it.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
1d5a3123ed Revert "luci-base: add urldecode() and urlencode() C implementations"
This reverts commit ad7dc4a492.

Since we're using liblucihttp now, that library is the appropriate place to
add such decoding helper functions.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
59dea0230c luci-base: switch to lucihttp based POST data processing
Use the liblucihttp provided multipart and x-www-urlencoded body parsers
and drop the old Lua parsing code.

The C based data parsers are way faster than their old Lua counterparts
while producing less string garbage and more correct results.

While refactoring the luci.http.protocol code, also drop unused functions
and dead code, heavily reducing the module size.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
f52c8d0b7f luci-base: switch to lucihttp.urldecode() and lucihttp.urlencode()
Drop the Lua implementation in luci.http.protocol and use the optimized C
variants of liblucihttp instead.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Qian Zheng
8e087a3d53 luci-base: zh_CN: update Simplified Chinese translation
Signed-off-by: Zheng Qian <sotux82@gmail.com>
2018-04-18 09:22:07 +08:00
Hannu Nyman
b2eceb0bcc i18n: sync translations, cleanup
* sync translations
* clean-up old strings from adblock

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-04-10 18:27:07 +03:00
Jo-Philipp Wich
2b516423a0 luci-base: fix rendering of 404 HTML error template
This 404 error template rendering has been broken for a long time due to bad
function environment level in luci.template when invoking the rendering from
the toplevel dispatcher context.

Fix this issue by adding a local function indirection, essentially adding an
additional stack frame.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-10 12:03:15 +02:00
Jo-Philipp Wich
48a5864f06 luci-base: error404: do not access request env directly
Instead of attempting to access the request environment directly (which does
not work anyway using the CGI SGI), use the already sanitized
dispatcher.context.request property to print out the not found url.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-10 12:01:43 +02:00
Jo-Philipp Wich
b194b8882e luci-base: don't propagate null bytes in path information
It is possible to inject unescaped markup using a double encoded null byte
via PATH_INFO on certain leaf nodes.

Since there is no legitimate reason to handle null bytes in any part of the
requested url, simply skip over such bytes when parsing the PATH_INFO value.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-10 11:41:32 +02:00
Jo-Philipp Wich
ad7dc4a492 luci-base: add urldecode() and urlencode() C implementations
The C implementations of urlencode and urldecode are considerably faster
than their current Lua counterparts.

On an AMD Geode system, the C variant is up to ten times faster when
decoding strings and up to four times faster when encoding them.

The functions are also designed to only allocate new strings when any
actual changes are required, otherwise they reuse the existing input
strings, reducing the overal memory usage somewhat.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-10 11:41:32 +02:00
Jo-Philipp Wich
b1b5723516 luci-base: consider empty parameters as well when testing POST requirement
The cbi class will react on an empty "cbi.submit" parameter as well so we
must intercept GET requests using that too.

Fixes 186e690c0 ("luci-base: dispatcher: reject non-POST requests with any cbi.submit value")

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-09 07:19:28 +02:00
Hannu Nyman
0ab0303527 i18n: sync translations
Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-04-08 20:38:30 +03:00
Hannu Nyman
c7369830b6 timezone data: update to 2018d
Update timezone data to 2018d

http://mm.icann.org/pipermail/tz-announce/2018-March/000049.html

  In 2018, Palestine starts DST on March 24, not March 31.
     Adjust future predictions accordingly.
  Casey Station in Antarctica changed from +11 to +08

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-04-07 23:26:29 +03:00
Jo-Philipp Wich
8c636c87ee luci-base: fix luci.model.uci.get_first()
Properly propagate the config parameter to the foreach iterator in order
to fix get_first() lookups.

Fixes #1734.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-07 14:09:18 +02:00
Jo-Philipp Wich
5c31937a0f luci-base: escape path strings and field parameter
Prevent various XSS vectors by not interpolating field and path values
verbatim into script and html contexts.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-07 11:43:44 +02:00
Jo-Philipp Wich
b00b676923 luci-base: properly initialize cbi.js on SimpleForms
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-06 16:39:39 +02:00
Jo-Philipp Wich
bf71ae5f1b luci-base: emit a warning if cbi() delegates a SimpleForm instance
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-06 12:07:49 +02:00
Jo-Philipp Wich
24ac0d81ee luci-base: implement luci.model.uci.get_state()
Introduce a get_state() function which can be used to access legacy
uci state variables. This is usually not needed anymore but some
packages (mainly mwan3) still rely on this.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-06 09:24:36 +02:00
Jo-Philipp Wich
4d6c5d284b luci-proto-ipv6: clarify 6in4 local address hint
Make the hint message more explicit to tell users that the prefix size needs
to be specified as well.

Fixes #1559.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-06 08:49:41 +02:00
Jo-Philipp Wich
7b04d0bbcf luci-base: introduce luci.dispatcher.lookup()
The lookup function takes multiple, possibly malformed path fragments,
splits them on slashes, constructs a temporary path and looks up the
result in the dispatch tree.

If a matching node has been found, the function will return both the
node reference and the canonical url to it.

If no corresponding node is found, the function returns nil.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-05 23:03:01 +02:00
Jo-Philipp Wich
ac2210376d
Merge pull request #1709 from dibdot/get_interface-fix
luci-base/network.lua: fix get_interface function
2018-04-05 09:49:49 +02:00
Jo-Philipp Wich
c0d9c4f3ce treewide: filter shell arguments through shellquote() where applicable
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-05 09:37:43 +02:00
Jo-Philipp Wich
45cefe71f6 luci-base: introduce luci.util.shellquote()
Introduce a new function luci.util.shellquote() which encloses the given
string argument in single quotes and escapes any embedded single quote
characters.

This function is intended to be used when interpolating untrusted input
into shell commands.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-05 09:37:43 +02:00
Jo-Philipp Wich
9db5fa93af luci-base: fix possible shell injection in luci.tools.status.switch_status()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-05 00:32:56 +02:00
Jo-Philipp Wich
186e690c08 luci-base: dispatcher: reject non-POST requests with any cbi.submit value
Due to the fact that luci.model.cbi reacts on any "cbi.submit" value while
the dispatcher only required POST for cbi.submit == 1, the CSRF token
protection could be bypassed.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-05 00:15:22 +02:00
Jo-Philipp Wich
053c343ef1 luci-base: use FULL_REQUEST_URI on login form templates
Switch from using the REQUEST_URI CGI variable directly to the canonicalized
FULL_REQUEST_URI property.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-04 23:30:49 +02:00
Jo-Philipp Wich
8c617c02b5 luci-base: add FULL_REQUEST_URI template property
Introduce a new template property FULL_REQUEST_URI which returns the full
canonicalized request URL built from SCRIPT_NAME, PATH_INFO and QUERY_STRING.

This new property is safer to use compared to using the raw REQUEST_URI CGI
environment variable directly as this value is essentially untrusted user
input which may contain embedded escaped slashes, double forward slashes and
other oddities allowing XSS exploitation or request redirection.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-04 23:24:31 +02:00
Jo-Philipp Wich
70ffbe65a0 luci-base: add a strict flag to the hostname validator
Some applications, e.g. dnsmasq, do not allow hostnames starting with an
underscore, therefor extend the existing hostname datatype validator with
a `strict` which disallows a leading underscore.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-04 23:21:53 +02:00
Jo-Philipp Wich
4024d4f224 luci-base: switch to ubus uci operations
Switch luci.model.uci to use ubus uci calls instead of driving libuci-lua
directly.

This prepares support for more advanced features such as per-session change
isolation and configuration rollback on errors.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-04 23:21:53 +02:00
Qian Zheng
46a2b5ebea luci-base: zh_CN: update Simplified Chinese translation
Signed-off-by: Qian Zheng <sotux82@gmail.com>
2018-04-02 11:49:47 +08:00
Dirk Brenken
87c2d95264 luci-base/network.lua: fix get_interface function
* fix wrong private function call to handle
  section id as parameter (fix for #1687)

Signed-off-by: Dirk Brenken <dev@brenken.org>
2018-03-31 07:11:02 +02:00
INAGAKI Hiroshi
caf4421603 i18n: sync translations
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2018-03-29 12:51:13 +09:00
Florian Eckert
70783f5802 luci-base: fix colspans calculation in tblsection
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-03-27 10:39:55 +02:00
Dirk Brenken
29d8770983 luci-base/util.lua: enhance checklib function
* enhance the checklib function in util.lua to check the 'fullpathexe'
  as well, e.g. this fixes runtime errors on the dhcp/dns template in
  environments without dnsmasq

Signed-off-by: Dirk Brenken <dev@brenken.org>
2018-03-22 10:40:42 +01:00
Jo-Philipp Wich
005f4fb7d4
Merge pull request #1654 from TDT-AG/pr/20180301-luci-several-fixes
luci-app-firewall/luci-base/luci-mod-admin-full: some fixes and improvements
2018-03-15 09:52:22 +01:00
Jo-Philipp Wich
28e3b32854 treewide: unify mac address handling
Use the new luci.ip MAC address facilities to parse and verify MAC addresses
in a common way, instead of relying on various ad-hoc solutions.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-12 16:12:18 +01:00
Jo-Philipp Wich
dfba318140 luci-base: fix documentation spelling mistakes in luci.http.protocol
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-12 16:04:52 +01:00
Jo-Philipp Wich
6d253abd99 luci-base: fix documentation spelling mistakes in luci.util
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-12 16:03:58 +01:00
Jo-Philipp Wich
62630fbf88 luci-base: fix parsing of ethers(5)
The /etc/ethers file may contain any number of white space characters
between the mac address and the IP/hostname field, so extend the pattern
to allow for that.

Man ethers(5) also states that the IP field may be a symbolic hostname,
so test whether the name is an IP address or hostname before adding it
to the hints structure.

Fixes #1674.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-11 18:26:31 +01:00
Hannu Nyman
bf04031171
Merge pull request #1675 from dibdot/material-fix
luci-base/firewall_zonelist: fix visual interface/background alignment
2018-03-09 18:54:32 +02:00
Dirk Brenken
21fbe39858 luci-base/firewall_zonelist: fix visual interface/background alignment
* fix for #1667, tested with all standard themes

Signed-off-by: Dirk Brenken <dev@brenken.org>
2018-03-09 08:13:03 +01:00
Jo-Philipp Wich
bf49505ea0 luci-base: properly handle undefined IPv6 local-address information
If IPv6 prefix assignment is disabled, the "local-address" structure
might exist, but be empty which causes the adress formatting in the
network model class to bail out.

Verify the completeness of the "local-address" structure before using
it in order to avoid runtime errors.

Fixes #1657.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-02 14:42:52 +01:00
Jo-Philipp Wich
852ec6e28b luci-base, luci-mod-admin-full: store backup vars in luci configuration
Keep the ifname and bridge state backup variables in /etc/config/luci to not
pollute /etc/config/network.

Fixes #1655.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-02 12:44:35 +01:00
Florian Eckert
fa756d1fbb luci-base: fix browser.htm template
If cbi_init() is not called first browser gif will not be found.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2018-03-01 12:31:50 +01:00
Jo-Philipp Wich
461df8b0dc luci-base: do not assume a fixed host address in delegated prefix (#1484)
OpenWrt/LEDE introduced the "local-address" field a while back to expose the
effective local host address of the delegated prefix, so use that information
instead of assuming `[prefix]:1`.

Fixes #1484.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-02-16 17:05:52 +01:00
Jo-Philipp Wich
de4f1c9046 luci-base: rework client side IP validation types and support "hostid" type
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-02-16 17:05:48 +01:00
Jo-Philipp Wich
3e1e4d5eb6 luci-base: fix Lua-side ip6hostid() datatype validation
A valid host ID as accepted by netifd must meet the following criteria:

 - Is either one of the two special "random" or "eui64" strings
 - Or is a valid IPv6 address according to inet_pton(AF_INET6)
 - Has the first 64 bit set to zero

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-02-16 17:05:48 +01:00
Vladimir
c21d22c017 i18n-ru: fixed russian translation
Signed-off-by: Vladimir <picfun@ya.ru>
2018-02-07 17:37:34 +03:00
Hannu Nyman
eae2f37b62 timezone data: update to 2018c
Update timezone data to 2018c

http://mm.icann.org/pipermail/tz-announce/2018-January/000048.html

   Briefly:
   Sao Tome and Príncipe switched from +00 to +01.
   Brazil's DST will now start on November's first Sunday.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-02-02 18:21:58 +02:00
Vladimir
4567512bdd i18n-ru: fixed and updated russian translation
Signed-off-by: Vladimir <picfun@ya.ru>
2018-01-30 17:35:30 +03:00
Vladimir
7133c51012 i18n-ru: fixed and updated russian translation
Signed-off-by: Vladimir <picfun@ya.ru>
2018-01-29 18:03:37 +03:00
Vladimir
d74ff878e1 i18n-ru: fixed and updated russian translation
Signed-off-by: Vladimir <picfun@ya.ru>
2018-01-26 16:57:15 +03:00
Vladimir
3467df984f i18n-ru: fixed simple-adblock strin&rus translation
Signed-off-by: Vladimir <picfun@ya.ru>

refine

refine
2018-01-23 13:40:18 +03:00
Vladimir
1295b6ca38 i18n-ru: fixed russian translation
Signed-off-by: Vladimir <picfun@ya.ru>
2018-01-21 19:48:47 +03:00
Vladimir
8a929a9551 i18n-sync base.po changes
Signed-off-by: Vladimir <picfun@ya.ru>
2018-01-20 16:09:35 +03:00
Vladimir
bb87aac852 i18n-ru: Edits on the general pattern of Russian translation
Signed-off-by: Vladimir <picfun@ya.ru>
2018-01-20 14:02:48 +03:00
Hannu Nyman
7062250701 luci-mod-admin-full: fix typos on dhcp page
Based on #1568

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-01-20 10:51:29 +02:00