mirror of
https://github.com/ipxe/ipxe
synced 2025-12-23 05:21:49 +03:00
[settings] Re-add "uristring" setting type
Commit09b057c("[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 commit09b057c("[settings] Remove "uristring" setting type"). Requested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user