summaryrefslogtreecommitdiff
path: root/src/libnm-glib-aux/nm-shared-utils.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-05-10 08:37:06 +0200
committerThomas Haller <thaller@redhat.com>2023-05-10 19:02:04 +0200
commitc26a94e95551021d86cae6fc0e6aafb97b1363f6 (patch)
tree65d5788a75cc6e00c0009f0e37dad15230d77a64 /src/libnm-glib-aux/nm-shared-utils.h
parentfed850b5b9e70a65e0aa4527c90332c478e3427f (diff)
downloadNetworkManager-c26a94e95551021d86cae6fc0e6aafb97b1363f6.tar.gz
glib-aux: add NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_DOUBLE_QUOTE flag to escape double quotes
This is useful when printing a string for debugging. Then we can printf("v=\"%s\"", utf8safe_escaped_text), which can be safely unescaped with `echo -e`.
Diffstat (limited to 'src/libnm-glib-aux/nm-shared-utils.h')
-rw-r--r--src/libnm-glib-aux/nm-shared-utils.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h
index 7233d77d40..60735d3c8d 100644
--- a/src/libnm-glib-aux/nm-shared-utils.h
+++ b/src/libnm-glib-aux/nm-shared-utils.h
@@ -1252,12 +1252,16 @@ typedef enum {
* It will backslash escape ascii characters according to nm_ascii_is_non_ascii(). */
NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_NON_ASCII = 0x0002,
+ /* Escape '"' as ASCII "\\042". This is useful when escaping a string so that
+ * it can be unescaped with `echo -e $PASTE_TEXT`. */
+ NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_DOUBLE_QUOTE = 0x0004,
+
/* This flag only has an effect during escaping to ensure we
* don't leak secrets in memory. Note that during unescape we
* know the maximum result size from the beginning, and no
* reallocation happens. Thus, unescape always avoids leaking
* secrets already. */
- NM_UTILS_STR_UTF8_SAFE_FLAG_SECRET = 0x0004,
+ NM_UTILS_STR_UTF8_SAFE_FLAG_SECRET = 0x0008,
/* This flag only has an effect during unescaping. It means
* that non-escaped whitespaces (g_ascii_isspace()) will be
@@ -1265,7 +1269,7 @@ typedef enum {
* this flag is only useful for gracefully accepting user input
* with spaces. With this flag, escape and unescape may no longer
* yield the original input. */
- NM_UTILS_STR_UTF8_SAFE_UNESCAPE_STRIP_SPACES = 0x0008,
+ NM_UTILS_STR_UTF8_SAFE_UNESCAPE_STRIP_SPACES = 0x0010,
} NMUtilsStrUtf8SafeFlags;
const char *nm_utils_buf_utf8safe_escape(gconstpointer buf,