From f638090179290c25cddce484df8ef59b9f05f6e7 Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Thu, 16 Jan 2025 17:20:27 +0530 Subject: [PATCH] fix(esp_http_client): Revert Deprecated Tag on Previously Marked Private API This commit removes depcriacted tag marked on priavte APIs' http_utils_get_string_between() and http_utils_get_string_after(). As these are not publick API, necessary changes been applied on these APIs' directly withput adding new similar one and marking them as depricated. --- components/esp_http_client/esp_http_client.c | 12 +++--- components/esp_http_client/lib/http_utils.c | 40 ++----------------- .../esp_http_client/lib/include/http_utils.h | 27 +------------ 3 files changed, 11 insertions(+), 68 deletions(-) diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index 39a2132121..22bb4c3154 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -1861,20 +1861,20 @@ esp_err_t esp_http_client_add_auth(esp_http_client_handle_t client) client->auth_data->method = strdup(HTTP_METHOD_MAPPING[client->connection_info.method]); client->auth_data->nc = 1; - HTTP_RET_ON_ERR_DBG(http_utils_get_substring_between(auth_header, "realm=\"", "\"", &client->auth_data->realm), TAG, "Unable to extract substring between specified strings"); - HTTP_RET_ON_ERR_DBG(http_utils_get_substring_between(auth_header, "algorithm=", ",", &client->auth_data->algorithm), TAG, "Unable to extract substring between specified strings"); + HTTP_RET_ON_ERR_DBG(http_utils_get_string_between(auth_header, "realm=\"", "\"", &client->auth_data->realm), TAG, "Unable to extract substring between specified strings"); + HTTP_RET_ON_ERR_DBG(http_utils_get_string_between(auth_header, "algorithm=", ",", &client->auth_data->algorithm), TAG, "Unable to extract substring between specified strings"); if (client->auth_data->algorithm == NULL) { - HTTP_RET_ON_ERR_DBG(http_utils_get_substring_after(auth_header, "algorithm=", &client->auth_data->algorithm), TAG, "Unable to extract substring after specified string"); + HTTP_RET_ON_ERR_DBG(http_utils_get_string_after(auth_header, "algorithm=", &client->auth_data->algorithm), TAG, "Unable to extract substring after specified string"); } if (client->auth_data->algorithm == NULL) { client->auth_data->algorithm = strdup("MD5"); } - HTTP_RET_ON_ERR_DBG(http_utils_get_substring_between(auth_header, "qop=\"", "\"", &client->auth_data->qop), TAG, "Unable to extract substring between specified strings"); - HTTP_RET_ON_ERR_DBG(http_utils_get_substring_between(auth_header, "nonce=\"", "\"", &client->auth_data->nonce), TAG, "Unable to extract substring between specified strings"); - HTTP_RET_ON_ERR_DBG(http_utils_get_substring_between(auth_header, "opaque=\"", "\"", &client->auth_data->opaque), TAG, "Unable to extract substring between specified strings"); + HTTP_RET_ON_ERR_DBG(http_utils_get_string_between(auth_header, "qop=\"", "\"", &client->auth_data->qop), TAG, "Unable to extract substring between specified strings"); + HTTP_RET_ON_ERR_DBG(http_utils_get_string_between(auth_header, "nonce=\"", "\"", &client->auth_data->nonce), TAG, "Unable to extract substring between specified strings"); + HTTP_RET_ON_ERR_DBG(http_utils_get_string_between(auth_header, "opaque=\"", "\"", &client->auth_data->opaque), TAG, "Unable to extract substring between specified strings"); client->process_again = 1; return ESP_OK; diff --git a/components/esp_http_client/lib/http_utils.c b/components/esp_http_client/lib/http_utils.c index 8e53fb1fd6..ec6a20fcf5 100644 --- a/components/esp_http_client/lib/http_utils.c +++ b/components/esp_http_client/lib/http_utils.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -110,41 +110,7 @@ void http_utils_trim_whitespace(char **str) memmove(*str, start, strlen(start) + 1); } -char *http_utils_get_string_between(const char *str, const char *begin, const char *end) -{ - char *found = strcasestr(str, begin); - char *ret = NULL; - if (found) { - found += strlen(begin); - char *found_end = strcasestr(found, end); - if (found_end) { - ret = calloc(1, found_end - found + 1); - mem_check(ret); - memcpy(ret, found, found_end - found); - return ret; - } - } - return NULL; -} - -char *http_utils_get_string_after(const char *str, const char *begin) -{ - char *found = strcasestr(str, begin); - char *ret = NULL; - if (found) { - found += strlen(begin); - char *found_end = (char *)str + strlen(str); - if (found_end) { - ret = calloc(1, found_end - found + 1); - mem_check(ret); - memcpy(ret, found, found_end - found); - return ret; - } - } - return NULL; -} - -esp_err_t http_utils_get_substring_between(const char *str, const char *begin, const char *end, char **out) +esp_err_t http_utils_get_string_between(const char *str, const char *begin, const char *end, char **out) { *out = NULL; char *found = strcasestr(str, begin); @@ -160,7 +126,7 @@ esp_err_t http_utils_get_substring_between(const char *str, const char *begin, c return ESP_OK; } -esp_err_t http_utils_get_substring_after(const char *str, const char *begin, char **out) +esp_err_t http_utils_get_string_after(const char *str, const char *begin, char **out) { *out = NULL; char *found = strcasestr(str, begin); diff --git a/components/esp_http_client/lib/include/http_utils.h b/components/esp_http_client/lib/include/http_utils.h index bd123bda78..3bb9d87ddf 100644 --- a/components/esp_http_client/lib/include/http_utils.h +++ b/components/esp_http_client/lib/include/http_utils.h @@ -80,29 +80,6 @@ char *http_utils_append_string(char **str, const char *new_str, int len); */ void http_utils_trim_whitespace(char **str); -/** - * @brief Gets the string between 2 string. - * It will allocate a new memory space for this string, so you need to free it when no longer use - * - * @param[in] str The source string - * @param[in] begin The begin string - * @param[in] end The end string - * - * @return The string between begin and end - */ -char *http_utils_get_string_between(const char *str, const char *begin, const char *end) __attribute__((deprecated("Use http_utils_get_substring_between instead.")));; - -/** - * @brief Returns a string that contains the part after the search string till the end of the source string. - * It will allocate a new memory space for this string, so you need to free it when no longer used - * - * @param[in] str The source string - * @param[in] begin The search string - * - * @return The string between begin and the end of str - */ -char *http_utils_get_string_after(const char *str, const char *begin) __attribute__((deprecated("Use http_utils_get_substring_after instead.")));; - /** * @brief Extracts the substring between two specified delimiters. * Allocates memory for the extracted substring and stores it in `out`. @@ -117,7 +94,7 @@ char *http_utils_get_string_after(const char *str, const char *begin) __attribut * - ESP_OK: Operation succeeded (even if no substring is found). * - ESP_ERR_NO_MEM: Memory allocation failed. */ -esp_err_t http_utils_get_substring_between(const char *str, const char *begin, const char *end, char **out); +esp_err_t http_utils_get_string_between(const char *str, const char *begin, const char *end, char **out); /** * @brief Extracts the substring starting after a specified delimiter until the end of the source string. @@ -132,7 +109,7 @@ esp_err_t http_utils_get_substring_between(const char *str, const char *begin, c * - ESP_OK: Operation succeeded (even if no substring is found). * - ESP_ERR_NO_MEM: Memory allocation failed. */ -esp_err_t http_utils_get_substring_after(const char *str, const char *begin, char **out); +esp_err_t http_utils_get_string_after(const char *str, const char *begin, char **out); /** * @brief Join 2 strings to one