urlapi: change more lowercase percent-encoded to uppercase

For consistency with other code, prefer uppercase.

Verified by test 1628
Reported-by: Fabian Keil
URL: https://curl.se/mail/lib-2026-05/0006.html
Closes #21592
This commit is contained in:
Daniel Stenberg 2026-05-13 16:06:00 +02:00
parent 7f7e4e3e68
commit 675a9b0189
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 61 additions and 7 deletions

View file

@ -1912,11 +1912,11 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
return cc2cu(result);
p = curlx_dyn_ptr(&enc);
while(*p) {
/* make sure percent encoded are lower case */
/* make sure percent encoded are upper case */
if((*p == '%') && ISXDIGIT(p[1]) && ISXDIGIT(p[2]) &&
(ISUPPER(p[1]) || ISUPPER(p[2]))) {
p[1] = Curl_raw_tolower(p[1]);
p[2] = Curl_raw_tolower(p[2]);
(ISLOWER(p[1]) || ISLOWER(p[2]))) {
p[1] = Curl_raw_toupper(p[1]);
p[2] = Curl_raw_toupper(p[2]);
p += 3;
}
else

View file

@ -214,6 +214,7 @@ test1596 test1597 test1598 test1599 test1600 test1601 test1602 test1603 \
test1604 test1605 test1606 test1607 test1608 test1609 test1610 test1611 \
test1612 test1613 test1614 test1615 test1616 test1617 test1618 test1619 \
test1620 test1621 test1622 test1623 test1624 test1625 test1626 test1627 \
test1628 \
\
test1630 test1631 test1632 test1633 test1634 test1635 test1636 test1637 \
test1638 test1639 test1640 test1641 test1642 test1643 test1644 \

View file

@ -44,7 +44,7 @@ content to _?!#$'|%LT%GT
# Verify data after the test has been "shot"
<verify>
<protocol crlf="yes" nonewline="yes">
POST /%TESTNUMBER?my+name+is+moo%5b%5d%AMPyes=s+i+r%AMPv_alue=content+to+_%3f%21%23%24%27%7c%3c%3e%0a%AMPcontent+to+_%3f%21%23%24%27%7c%3c%3e%0a%AMP%3d%3d HTTP/1.1
POST /%TESTNUMBER?my+name+is+moo%5B%5D%AMPyes=s+i+r%AMPv_alue=content+to+_%3F%21%23%24%27%7C%3C%3E%0A%AMPcontent+to+_%3F%21%23%24%27%7C%3C%3E%0A%AMP%3D%3D HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*

53
tests/data/test1628 Normal file
View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP PUT
</keywords>
</info>
# Server-side
<reply>
<data>
HTTP/1.0 200 OK swsclose
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
blablabla
</data>
</reply>
# Client-side
<client>
<features>
proxy
</features>
<server>
http
</server>
<name>
HTTP PUT from file with weird letters over a HTTP proxy
</name>
<command>
-x http://%HOSTIP:%HTTPPORT http://ssss/ -T %LOGDIR/%TESTNUMBERte[]st.txt
</command>
<file name="%LOGDIR/%TESTNUMBERte[]st.txt">
a few bytes
</file>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol crlf="headers">
PUT http://ssss/%TESTNUMBERte%5B%5Dst.txt HTTP/1.1
Host: ssss
User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 12
a few bytes
</protocol>
</verify>
</testcase>

View file

@ -1137,8 +1137,8 @@ static const struct setcase set_parts_list[] = {
"https://host:1234/",
0, 0, CURLUE_OK, CURLUE_BAD_PORT_NUMBER},
{"https://host/",
"path=%4A%4B%4C,",
"https://host/%4a%4b%4c",
"path=%4A%4b%4C,",
"https://host/%4A%4B%4C",
0, 0, CURLUE_OK, CURLUE_OK},
{"https://host/mooo?q#f",
"path=NULL,query=NULL,fragment=NULL,",