]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
escape: replace Curl_isunreserved with ISUNRESERVED
authorJay Satiro <raysatiro@yahoo.com>
Wed, 13 Sep 2023 18:41:51 +0000 (14:41 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Thu, 14 Sep 2023 07:07:45 +0000 (03:07 -0400)
- Use the ALLCAPS version of the macro so that it is clear a macro is
  being called that evaluates the variable multiple times.

- Also capitalize macro isurlpuntcs => ISURLPUNTCS since it evaluates
  a variable multiple times.

This is a follow-up to 291d225a which changed Curl_isunreserved into an
alias macro for ISUNRESERVED. The problem is the former is not easily
identified as a macro by the caller, which could lead to a bug.

For example, ISUNRESERVED(*foo++) is easily identifiable as wrong but
Curl_isunreserved(*foo++) is not even though they both are the same.

Closes https://github.com/curl/curl/pull/11846

lib/curl_ctype.h
lib/escape.c
lib/escape.h
lib/urlapi.c

index c7b370c592139326e26ebbb8acf7bf9972e33a0e..7f0d0cc2916d08e63a9373708fdacc1c4ed7f490 100644 (file)
@@ -43,9 +43,9 @@
 #define ISDIGIT(x)  (((x) >= '0') && ((x) <= '9'))
 #define ISBLANK(x)  (((x) == ' ') || ((x) == '\t'))
 #define ISSPACE(x)  (ISBLANK(x) || (((x) >= 0xa) && ((x) <= 0x0d)))
-#define isurlpuntcs(x) (((x) == '-') || ((x) == '.') || ((x) == '_') || \
+#define ISURLPUNTCS(x) (((x) == '-') || ((x) == '.') || ((x) == '_') || \
                         ((x) == '~'))
-#define ISUNRESERVED(x) (ISALNUM(x) || isurlpuntcs(x))
+#define ISUNRESERVED(x) (ISALNUM(x) || ISURLPUNTCS(x))
 
 
 #endif /* HEADER_CURL_CTYPE_H */
index 2fc1d1ee56ea288fce9f3575bf1fec4ff79e3232..0f35bed0af9c5cb3b4e56b42aa834c88a7e01b22 100644 (file)
@@ -72,7 +72,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
   while(length--) {
     unsigned char in = *string++; /* treat the characters unsigned */
 
-    if(Curl_isunreserved(in)) {
+    if(ISUNRESERVED(in)) {
       /* append this */
       if(Curl_dyn_addn(&d, &in, 1))
         return NULL;
index b9fd272f6b9772ae2692346f74257267824129be..caa4aa533198d4258ae83d4c2611f482a4c128a0 100644 (file)
@@ -28,8 +28,6 @@
 
 #include "curl_ctype.h"
 
-#define Curl_isunreserved(x) ISUNRESERVED(x)
-
 enum urlreject {
   REJECT_NADA = 2,
   REJECT_CTRL,
index 80299e7c0e2b0ec37e861a68186c22a66ba56754..552b43102659978118915b29d20efee7d227cd8a 100644 (file)
@@ -1865,7 +1865,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
           if(result)
             return CURLUE_OUT_OF_MEMORY;
         }
-        else if(Curl_isunreserved(*i) ||
+        else if(ISUNRESERVED(*i) ||
                 ((*i == '/') && urlskipslash) ||
                 ((*i == '=') && equalsencode)) {
           if((*i == '=') && equalsencode)