From 489a4c1b48096db7df4875af0bedf4f7d0973382 Mon Sep 17 00:00:00 2001 From: Alhuda Khan Date: Thu, 23 Jul 2026 12:09:04 +0530 Subject: [PATCH] ctype: exclude control bytes from ISPRINT and ISGRAPH Closes #22371 --- lib/curl_ctype.h | 6 ++---- tests/unit/unit1307.c | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/curl_ctype.h b/lib/curl_ctype.h index f3291ad818..fd6b7d723c 100644 --- a/lib/curl_ctype.h +++ b/lib/curl_ctype.h @@ -30,10 +30,8 @@ #define ISLOWCNTRL(x) ((unsigned char)(x) <= 0x1f) #define IS7F(x) ((x) == 0x7f) -#define ISLOWPRINT(x) (((x) >= 9) && ((x) <= 0x0d)) - -#define ISPRINT(x) (ISLOWPRINT(x) || (((x) >= ' ') && ((x) <= 0x7e))) -#define ISGRAPH(x) (ISLOWPRINT(x) || (((x) > ' ') && ((x) <= 0x7e))) +#define ISPRINT(x) (((x) >= ' ') && ((x) <= 0x7e)) +#define ISGRAPH(x) (((x) > ' ') && ((x) <= 0x7e)) #define ISCNTRL(x) (ISLOWCNTRL(x) || IS7F(x)) #define ISALPHA(x) (ISLOWER(x) || ISUPPER(x)) #define ISXDIGIT(x) (ISDIGIT(x) || ISLOWHEXALPHA(x) || ISUPHEXALPHA(x)) diff --git a/tests/unit/unit1307.c b/tests/unit/unit1307.c index 833319b611..c45dc81c77 100644 --- a/tests/unit/unit1307.c +++ b/tests/unit/unit1307.c @@ -174,10 +174,15 @@ static CURLcode test_unit1307(const char *arg) { "[[:print:]]", "L", MATCH }, { "[[:print:]]", "\10", NOMATCH }, { "[[:print:]]", "\10", NOMATCH }, + { "[[:print:]]", "\t", NOMATCH }, + { "[[:print:]]", "\n", NOMATCH }, + { "[[:print:]]", "\r", NOMATCH }, { "[[:space:]]", " ", MATCH }, { "[[:space:]]", "x", NOMATCH }, { "[[:graph:]]", " ", NOMATCH }, { "[[:graph:]]", "x", MATCH }, + { "[[:graph:]]", "\t", NOMATCH }, + { "[[:graph:]]", "\r", NOMATCH }, { "[[:blank:]]", "\t", MATCH }, { "[[:blank:]]", " ", MATCH }, { "[[:blank:]]", "\r", NOMATCH },