1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 00:03:12 +02:00

relay/api: consider boolean/long query string parameters as invalid if they are empty

This commit is contained in:
Sébastien Helleu
2025-10-26 18:12:02 +01:00
parent df3232fc80
commit 93d73d234f
2 changed files with 11 additions and 5 deletions
+7 -3
View File
@@ -170,12 +170,12 @@ relay_http_url_decode (const char *url)
}
/*
* Reads value of an URL parameter as boolean (0 or 1) into *value.
* Reads value of a query string parameter as boolean (0 or 1) into *value.
* If the parameter is not in URL, the default value is used.
*
* Returns:
* 1: OK, *value is set
* 0: error (URL parameter has invalid format)
* 0: error (query string parameter has invalid format)
*/
int
@@ -189,6 +189,8 @@ relay_http_get_param_boolean (struct t_relay_http_request *request,
return 0;
ptr_value = weechat_hashtable_get (request->params, name);
if (ptr_value && !ptr_value[0])
return 0;
*value = (ptr_value) ?
weechat_config_string_to_boolean (ptr_value) : default_value;
@@ -196,7 +198,7 @@ relay_http_get_param_boolean (struct t_relay_http_request *request,
}
/*
* Reads value of an URL parameter as long into *value.
* Reads value of a query string parameter as long into *value.
* If the parameter is not in URL, the default value is used.
*
* Returns:
@@ -217,6 +219,8 @@ relay_http_get_param_long (struct t_relay_http_request *request,
return 0;
ptr_value = weechat_hashtable_get (request->params, name);
if (ptr_value && !ptr_value[0])
return 0;
if (ptr_value)
{
number = strtol (ptr_value, &error, 10);