NetworkManager/shared
Thomas Haller e206e3d4d8 shared: add nm_utils_escaped_tokens_escape()
This escapes strings so that they can be concatenated with a delimiter
and without loss tokenized with nm_utils_escaped_tokens_split().

Note that this is similar to _nm_utils_escape_plain() and
_nm_utils_escape_spaces(). The difference is that
nm_utils_escaped_tokens_escape() also escapes the last trailing
whitespace. That means, if delimiters contains all NM_ASCII_SPACES, then
it is identical to _nm_utils_escape_spaces(). Otherwise, the trailing
space is treated specially. That is, because
nm_utils_escaped_tokens_split() uses NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP,
to strip leading and trailing whitespace. To still express a trailing
whitespace, the last whitespace must be escaped. Note that
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP also honors escaping any whitespace
(not only at the last position), but when escaping we don't need to
escape them, because unescaped (non-trailing) whitespace are taken just
fine.

The pair nm_utils_escaped_tokens_split() and
nm_utils_escaped_tokens_escape() are proposed as default way of
tokenizing a list of items. For example, with

  $ nmcli connection modify "$PROFILE" +ipv4.routing-rules 'priority 5 from 192.168.7.5/32 table 5, priority 6 iif a\, from 192.168.7.5/32 table 6'

Here we implement a to/from string function to handle one item
(nm_ip_routing_rule_{from,to}_string()). When such elements are combined with ',',
then we need to support an additional layer of escaping on top of that.
The advantage is that the indvidual to/from string functions are agnostic
to this second layer of escaping/tokenizing that nmcli employs to handle
a list of these items.
The disadvantage is that we possibly get multiple layers of backslash
escapings. That is only mitigated by the fact that nm_utils_escaped_tokens_*()
supports a syntax for which *most* characters don't need any special escaping.
Only delimiters, backslash, and the trailing space needs escaping, and
these are cases are expected to be few.
2019-04-17 11:11:21 +02:00
..
c-list shared/c-list: reimport 2019-04-14 17:22:04 +02:00
c-rbtree shared/c-rbtree: reimport 2019-04-14 17:23:01 +02:00
c-siphash shared/c-siphash: reimport 2019-04-14 17:23:25 +02:00
c-stdaux shared: patch c-stdaux.h to not include <stdatomic.h> 2019-04-14 17:17:52 +02:00
n-acd shared/n-acd: reimport 2019-04-14 17:23:50 +02:00
nm-utils shared: add nm_utils_escaped_tokens_escape() 2019-04-17 11:11:21 +02:00
systemd libnm,shared: bzero secrets on failure in nm_utils_base64secret_decode() 2019-04-12 07:39:50 +02:00
meson.build build: include c-stdaux in c-util and nettools tools 2019-04-14 12:59:48 +02:00
nm-common-macros.h Add polkit action for Wi-Fi scans 2019-02-21 13:49:17 +01:00
nm-dbus-compat.h build: rename directory "include" to "shared" 2015-12-24 11:42:37 +01:00
nm-default.h all: goodbye libnm-glib 2019-04-16 15:52:27 +02:00
nm-dispatcher-api.h build: cleanup src/Makefile.am 2016-08-11 11:54:18 +02:00
nm-ethtool-utils.c shared: fix static array declaration for _by_name in "nm-ethtool-utils.c" 2019-02-08 20:14:50 +01:00
nm-ethtool-utils.h all/ethtool: add support for all currently supported kernel features 2018-08-10 10:38:19 +02:00
nm-libnm-core-utils.c libnm: move parsing VLAN priority mapping to "shared/nm-libnm-core-utils.h" 2019-03-25 09:12:32 +01:00
nm-libnm-core-utils.h libnm/infiniband: lift restriction of MTU to 2044 for IPoIB in "datagram" mode 2019-04-05 16:27:17 +02:00
nm-meta-setting.c shared: add set function to nm_setting_8021x_scheme_vtable 2019-03-25 09:12:32 +01:00
nm-meta-setting.h shared: add set function to nm_setting_8021x_scheme_vtable 2019-03-25 09:12:32 +01:00
nm-test-libnm-utils.h all: goodbye libnm-glib 2019-04-16 15:52:27 +02:00
nm-test-utils-impl.c all: goodbye libnm-glib 2019-04-16 15:52:27 +02:00
nm-version-macros.h.in release: bump version to 1.19.0 (development) 2019-04-13 18:54:31 +02:00