Ver código fonte

[settings] Remove "uristring" setting type

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>
tags/v1.20.1
Michael Brown 10 anos atrás
pai
commit
09b057ce84
2 arquivos alterados com 5 adições e 62 exclusões
  1. 5
    49
      src/core/settings.c
  2. 0
    13
      src/tests/settings_test.c

+ 5
- 49
src/core/settings.c Ver arquivo

@@ -1658,59 +1658,15 @@ const struct setting_type setting_type_string __setting_type = {
1658 1658
 	.format = format_string_setting,
1659 1659
 };
1660 1660
 
1661
-/**
1662
- * Parse URI-encoded string setting value
1661
+/** A URI-encoded string setting type
1663 1662
  *
1664
- * @v type		Setting type
1665
- * @v value		Formatted setting value
1666
- * @v buf		Buffer to contain raw value
1667
- * @v len		Length of buffer
1668
- * @ret len		Length of raw value, or negative error
1663
+ * This setting type is obsolete; the name ":uristring" is retained to
1664
+ * avoid breaking existing scripts.
1669 1665
  */
1670
-static int parse_uristring_setting ( const struct setting_type *type __unused,
1671
-				     const char *value, void *buf, size_t len ){
1672
-	char tmp[ len + 1 /* NUL */ ];
1673
-	size_t raw_len;
1674
-
1675
-	/* Decode to temporary buffer (including NUL) */
1676
-	raw_len = uri_decode ( value, tmp, sizeof ( tmp ) );
1677
-
1678
-	/* Copy to output buffer (excluding NUL) */
1679
-	if ( len > raw_len )
1680
-		len = raw_len;
1681
-	memcpy ( buf, tmp, len );
1682
-
1683
-	return raw_len;
1684
-}
1685
-
1686
-/**
1687
- * Format URI-encoded string setting value
1688
- *
1689
- * @v type		Setting type
1690
- * @v raw		Raw setting value
1691
- * @v raw_len		Length of raw setting value
1692
- * @v buf		Buffer to contain formatted value
1693
- * @v len		Length of buffer
1694
- * @ret len		Length of formatted value, or negative error
1695
- */
1696
-static int format_uristring_setting ( const struct setting_type *type __unused,
1697
-				      const void *raw, size_t raw_len,
1698
-				      char *buf, size_t len ) {
1699
-	char tmp[ raw_len + 1 /* NUL */ ];
1700
-
1701
-	/* Copy to temporary buffer and terminate */
1702
-	memcpy ( tmp, raw, raw_len );
1703
-	tmp[raw_len] = '\0';
1704
-
1705
-	/* Encode directly into output buffer */
1706
-	return uri_encode ( tmp, buf, len, URI_FRAGMENT );
1707
-}
1708
-
1709
-/** A URI-encoded string setting type */
1710 1666
 const struct setting_type setting_type_uristring __setting_type = {
1711 1667
 	.name = "uristring",
1712
-	.parse = parse_uristring_setting,
1713
-	.format = format_uristring_setting,
1668
+	.parse = parse_string_setting,
1669
+	.format = format_string_setting,
1714 1670
 };
1715 1671
 
1716 1672
 /**

+ 0
- 13
src/tests/settings_test.c Ver arquivo

@@ -162,12 +162,6 @@ static struct setting test_string_setting = {
162 162
 	.type = &setting_type_string,
163 163
 };
164 164
 
165
-/** Test URI-encoded string setting */
166
-static struct setting test_uristring_setting = {
167
-	.name = "test_uristring",
168
-	.type = &setting_type_uristring,
169
-};
170
-
171 165
 /** Test IPv4 address setting type */
172 166
 static struct setting test_ipv4_setting = {
173 167
 	.name = "test_ipv4",
@@ -261,13 +255,6 @@ static void settings_test_exec ( void ) {
261 255
 	fetchf_ok ( &test_settings, &test_string_setting,
262 256
 		    RAW ( 'w', 'o', 'r', 'l', 'd' ), "world" );
263 257
 
264
-	/* "uristring" setting type */
265
-	storef_ok ( &test_settings, &test_uristring_setting, "hello%20world",
266
-		    RAW ( 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l',
267
-			  'd' ) );
268
-	fetchf_ok ( &test_settings, &test_uristring_setting,
269
-		    RAW ( 1, 2, 3, 4, 5 ), "%01%02%03%04%05" );
270
-
271 258
 	/* "ipv4" setting type */
272 259
 	storef_ok ( &test_settings, &test_ipv4_setting, "192.168.0.1",
273 260
 		    RAW ( 192, 168, 0, 1 ) );

Carregando…
Cancelar
Salvar