diff --git a/src/core/settings.c b/src/core/settings.c index 1f742548..5e16b27d 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -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, }; /** diff --git a/src/tests/settings_test.c b/src/tests/settings_test.c index 5da31b4c..4ee6a10f 100644 --- a/src/tests/settings_test.c +++ b/src/tests/settings_test.c @@ -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 ) );