lib: use ISBLANK and ISNEWLINE more

Closes #20373
This commit is contained in:
Daniel Stenberg 2026-01-20 12:07:15 +01:00
parent 09c9afdd71
commit 3c957ad1fe
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 12 additions and 24 deletions

View File

@ -437,13 +437,12 @@ static CURLcode imap_get_message(struct Curl_easy *data, struct bufref *out)
if(len > 2) {
/* Find the start of the message */
len -= 2;
for(message += 2; *message == ' ' || *message == '\t'; message++, len--)
for(message += 2; ISBLANK(*message); message++, len--)
;
/* Find the end of the message */
while(len--)
if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
message[len] != '\t')
if(!ISNEWLINE(message[len]) && !ISBLANK(message[len]))
break;
/* Terminate the message */
@ -1035,20 +1034,15 @@ static CURLcode imap_state_capability_resp(struct Curl_easy *data,
/* Loop through the data line */
for(;;) {
size_t wordlen;
while(*line &&
(*line == ' ' || *line == '\t' ||
*line == '\r' || *line == '\n')) {
while(*line && (ISBLANK(*line) || ISNEWLINE(*line)))
line++;
}
if(!*line)
break;
/* Extract the word */
for(wordlen = 0; line[wordlen] && line[wordlen] != ' ' &&
line[wordlen] != '\t' && line[wordlen] != '\r' &&
line[wordlen] != '\n';)
for(wordlen = 0; line[wordlen] && !ISBLANK(line[wordlen]) &&
!ISNEWLINE(line[wordlen]);)
wordlen++;
/* Does the server support the STARTTLS capability? */

View File

@ -358,13 +358,12 @@ static CURLcode pop3_get_message(struct Curl_easy *data, struct bufref *out)
if(len > 2) {
/* Find the start of the message */
len -= 2;
for(message += 2; *message == ' ' || *message == '\t'; message++, len--)
for(message += 2; ISBLANK(*message); message++, len--)
;
/* Find the end of the message */
while(len--)
if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
message[len] != '\t')
if(!ISBLANK(message[len]) && !ISNEWLINE(message[len]))
break;
/* Terminate the message */

View File

@ -547,13 +547,12 @@ static CURLcode smtp_get_message(struct Curl_easy *data, struct bufref *out)
if(len > 4) {
/* Find the start of the message */
len -= 4;
for(message += 4; *message == ' ' || *message == '\t'; message++, len--)
for(message += 4; ISBLANK(*message); message++, len--)
;
/* Find the end of the message */
while(len--)
if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
message[len] != '\t')
if(!ISNEWLINE(message[len]) && !ISBLANK(message[len]))
break;
/* Terminate the message */
@ -1234,10 +1233,7 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data,
size_t wordlen;
unsigned short mechbit;
while(len &&
(*line == ' ' || *line == '\t' ||
*line == '\r' || *line == '\n')) {
while(len && (ISBLANK(*line) || ISNEWLINE(*line))) {
line++;
len--;
}
@ -1246,9 +1242,8 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data,
break;
/* Extract the word */
for(wordlen = 0; wordlen < len && line[wordlen] != ' ' &&
line[wordlen] != '\t' && line[wordlen] != '\r' &&
line[wordlen] != '\n';)
for(wordlen = 0; wordlen < len && !ISBLANK(line[wordlen]) &&
!ISNEWLINE(line[wordlen]);)
wordlen++;
/* Test the word for a matching authentication mechanism */