summaryrefslogtreecommitdiffstats
path: root/src/core/settings.c
diff options
context:
space:
mode:
authorMichael Brown2015-08-25 13:33:40 +0200
committerMichael Brown2015-08-25 14:31:46 +0200
commitba3695353add020b686547699ba5e259c339bfa6 (patch)
treed400084f87152adbbbc7dbca3140c1c2789c03b0 /src/core/settings.c
parent[autoboot] Display image information as part of the default control flow (diff)
downloadipxe-ba3695353add020b686547699ba5e259c339bfa6.tar.gz
ipxe-ba3695353add020b686547699ba5e259c339bfa6.tar.xz
ipxe-ba3695353add020b686547699ba5e259c339bfa6.zip
[settings] Re-add "uristring" setting type
Commit 09b057c ("[settings] Remove "uristring" setting type") removed support for URI-encoded settings via the "uristring" setting type, on the basis that such encoding was no longer necessary to avoid problems with the command line parser. Other valid use cases for the "uristring" setting type do exist: for example, a password containing a '/' character expanded via chain http://username:${password:uristring}@server.name/boot.php Restore the existence of the "uristring" setting, avoiding the potentially large stack allocations that were used in the old code prior to commit 09b057c ("[settings] Remove "uristring" setting type"). Requested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/settings.c')
-rw-r--r--src/core/settings.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/core/settings.c b/src/core/settings.c
index 12e6c7d6..f6f62d22 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -1666,15 +1666,43 @@ const struct setting_type setting_type_string __setting_type = {
.format = format_string_setting,
};
-/** A URI-encoded string setting type
+/**
+ * Parse URI-encoded string setting value
*
- * This setting type is obsolete; the name ":uristring" is retained to
- * avoid breaking existing scripts.
+ * @v type Setting type
+ * @v value Formatted setting value
+ * @v buf Buffer to contain raw value
+ * @v len Length of buffer
+ * @ret len Length of raw value, or negative error
*/
+static int parse_uristring_setting ( const struct setting_type *type __unused,
+ const char *value, void *buf, size_t len ){
+
+ return uri_decode ( value, buf, len );
+}
+
+/**
+ * Format URI-encoded string setting value
+ *
+ * @v type Setting type
+ * @v raw Raw setting value
+ * @v raw_len Length of raw setting value
+ * @v buf Buffer to contain formatted value
+ * @v len Length of buffer
+ * @ret len Length of formatted value, or negative error
+ */
+static int format_uristring_setting ( const struct setting_type *type __unused,
+ const void *raw, size_t raw_len,
+ char *buf, size_t len ) {
+
+ return uri_encode ( 0, raw, raw_len, buf, len );
+}
+
+/** A URI-encoded string setting type */
const struct setting_type setting_type_uristring __setting_type = {
.name = "uristring",
- .parse = parse_string_setting,
- .format = format_string_setting,
+ .parse = parse_uristring_setting,
+ .format = format_uristring_setting,
};
/**