diff options
author | Michael Brown <mcb30@ipxe.org> | 2015-08-25 12:33:40 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2015-08-25 13:31:46 +0100 |
commit | ba3695353add020b686547699ba5e259c339bfa6 (patch) | |
tree | d400084f87152adbbbc7dbca3140c1c2789c03b0 /src/tests | |
parent | 4e03af8ec2d497e725566a91fd5c19dd604c18a6 (diff) | |
download | ipxe-ba3695353add020b686547699ba5e259c339bfa6.zip ipxe-ba3695353add020b686547699ba5e259c339bfa6.tar.gz ipxe-ba3695353add020b686547699ba5e259c339bfa6.tar.bz2 |
[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/tests')
-rw-r--r-- | src/tests/settings_test.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tests/settings_test.c b/src/tests/settings_test.c index f7fb35d..89203d4 100644 --- a/src/tests/settings_test.c +++ b/src/tests/settings_test.c @@ -166,6 +166,12 @@ 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", @@ -265,6 +271,16 @@ 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" ); + fetchf_ok ( &test_settings, &test_uristring_setting, + RAW ( 0, ' ', '%', '/', '#', ':', '@', '?', '=', '&' ), + "%00%20%25%2F%23%3A%40%3F%3D%26" ); + /* "ipv4" setting type */ storef_ok ( &test_settings, &test_ipv4_setting, "192.168.0.1", RAW ( 192, 168, 0, 1 ) ); |