]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[settings] Remove "uristring" setting type
authorMichael Brown <mcb30@ipxe.org>
Mon, 17 Feb 2014 16:14:25 +0000 (16:14 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 26 Feb 2014 23:34:07 +0000 (23:34 +0000)
Commit b5f5f73 ("[cmdline] Expand settings within each command-line
token individually") effectively rendered the "uristring" setting type
obsolete, since strings containing whitespace no longer break the
command line parser.  The concept of the "uristring" type is not well
defined, since URI escaping rules depend on which portion of a URI is
being escaped.

Remove the "uristring" type, converting it into an alias for the
"string" setting type so as to avoid breaking existing scripts.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/settings.c
src/tests/settings_test.c

index 1f74254822bae61a6d60d53ca3a68f5e15d13818..5e16b27d0ef4bbc06b378d9d57ab64662428648a 100644 (file)
@@ -1658,59 +1658,15 @@ const struct setting_type setting_type_string __setting_type = {
        .format = format_string_setting,
 };
 
-/**
- * Parse URI-encoded string setting value
+/** A URI-encoded string setting type
  *
- * @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
+ * This setting type is obsolete; the name ":uristring" is retained to
+ * avoid breaking existing scripts.
  */
-static int parse_uristring_setting ( const struct setting_type *type __unused,
-                                    const char *value, void *buf, size_t len ){
-       char tmp[ len + 1 /* NUL */ ];
-       size_t raw_len;
-
-       /* Decode to temporary buffer (including NUL) */
-       raw_len = uri_decode ( value, tmp, sizeof ( tmp ) );
-
-       /* Copy to output buffer (excluding NUL) */
-       if ( len > raw_len )
-               len = raw_len;
-       memcpy ( buf, tmp, len );
-
-       return raw_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 ) {
-       char tmp[ raw_len + 1 /* NUL */ ];
-
-       /* Copy to temporary buffer and terminate */
-       memcpy ( tmp, raw, raw_len );
-       tmp[raw_len] = '\0';
-
-       /* Encode directly into output buffer */
-       return uri_encode ( tmp, buf, len, URI_FRAGMENT );
-}
-
-/** A URI-encoded string setting type */
 const struct setting_type setting_type_uristring __setting_type = {
        .name = "uristring",
-       .parse = parse_uristring_setting,
-       .format = format_uristring_setting,
+       .parse = parse_string_setting,
+       .format = format_string_setting,
 };
 
 /**
index 5da31b4ce8053b86d9ac4ba98e82e480623bc644..4ee6a10fa7c783f4fbe97a4731f628425149c6ea 100644 (file)
@@ -162,12 +162,6 @@ static struct setting test_string_setting = {
        .type = &setting_type_string,
 };
 
-/** Test URI-encoded string setting */
-static struct setting test_uristring_setting = {
-       .name = "test_uristring",
-       .type = &setting_type_uristring,
-};
-
 /** Test IPv4 address setting type */
 static struct setting test_ipv4_setting = {
        .name = "test_ipv4",
@@ -261,13 +255,6 @@ static void settings_test_exec ( void ) {
        fetchf_ok ( &test_settings, &test_string_setting,
                    RAW ( 'w', 'o', 'r', 'l', 'd' ), "world" );
 
-       /* "uristring" setting type */
-       storef_ok ( &test_settings, &test_uristring_setting, "hello%20world",
-                   RAW ( 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l',
-                         'd' ) );
-       fetchf_ok ( &test_settings, &test_uristring_setting,
-                   RAW ( 1, 2, 3, 4, 5 ), "%01%02%03%04%05" );
-
        /* "ipv4" setting type */
        storef_ok ( &test_settings, &test_ipv4_setting, "192.168.0.1",
                    RAW ( 192, 168, 0, 1 ) );