mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
util/uri: Remove the uri_string_escape() function
Now that uri_resolve_relative() has been removed, this function is not used in QEMU anymore - and if somebody needs this functionality, they can simply use g_uri_escape_string() from the glib instead. Reviewed-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: "Daniel P. Berrangé" <berrange@redhat.com> Message-ID: <20240123182247.432642-4-thuth@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
fdd16f16f4
commit
8fd466737c
2 changed files with 0 additions and 71 deletions
|
@ -76,7 +76,6 @@ URI *uri_parse(const char *str);
|
|||
URI *uri_parse_raw(const char *str, int raw);
|
||||
int uri_parse_into(URI *uri, const char *str);
|
||||
char *uri_to_string(URI *uri);
|
||||
char *uri_string_escape(const char *str, const char *list);
|
||||
void uri_free(URI *uri);
|
||||
|
||||
/* Single web service query parameter 'name=value'. */
|
||||
|
|
70
util/uri.c
70
util/uri.c
|
@ -1349,76 +1349,6 @@ void uri_free(URI *uri)
|
|||
g_free(uri);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Helper functions *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* uri_string_escape:
|
||||
* @str: string to escape
|
||||
* @list: exception list string of chars not to escape
|
||||
*
|
||||
* This routine escapes a string to hex, ignoring reserved characters (a-z)
|
||||
* and the characters in the exception list.
|
||||
*
|
||||
* Returns a new escaped string or NULL in case of error.
|
||||
*/
|
||||
char *uri_string_escape(const char *str, const char *list)
|
||||
{
|
||||
char *ret, ch;
|
||||
char *temp;
|
||||
const char *in;
|
||||
int len, out;
|
||||
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (str[0] == 0) {
|
||||
return g_strdup(str);
|
||||
}
|
||||
len = strlen(str);
|
||||
if (!(len > 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len += 20;
|
||||
ret = g_malloc(len);
|
||||
in = str;
|
||||
out = 0;
|
||||
while (*in != 0) {
|
||||
if (len - out <= 3) {
|
||||
temp = realloc2n(ret, &len);
|
||||
ret = temp;
|
||||
}
|
||||
|
||||
ch = *in;
|
||||
|
||||
if ((ch != '@') && (!IS_UNRESERVED(ch)) && (!strchr(list, ch))) {
|
||||
unsigned char val;
|
||||
ret[out++] = '%';
|
||||
val = ch >> 4;
|
||||
if (val <= 9) {
|
||||
ret[out++] = '0' + val;
|
||||
} else {
|
||||
ret[out++] = 'A' + val - 0xA;
|
||||
}
|
||||
val = ch & 0xF;
|
||||
if (val <= 9) {
|
||||
ret[out++] = '0' + val;
|
||||
} else {
|
||||
ret[out++] = 'A' + val - 0xA;
|
||||
}
|
||||
in++;
|
||||
} else {
|
||||
ret[out++] = *in++;
|
||||
}
|
||||
}
|
||||
ret[out] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Public functions *
|
||||
|
|
Loading…
Reference in a new issue