Skip to content

Commit 3ae61e4

Browse files
TimWollaedorian
authored andcommitted
uri: Update to uriparser-0.9.9-79-gf47a7f0 (#20671)
This is in preparation of importing a fix for the uriparser/uriparser#282 security issue, which will likely depend on this refactoring to cleanly apply.
1 parent 671f95e commit 3ae61e4

File tree

12 files changed

+253
-1120
lines changed

12 files changed

+253
-1120
lines changed

ext/uri/uriparser/src/UriCommon.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
# ifndef URI_DOXYGEN
6363
# include <uriparser/Uri.h>
6464
# include "UriCommon.h"
65+
# include "UriSets.h"
6566
# endif
6667

6768
# include <assert.h>
@@ -468,32 +469,11 @@ UriBool URI_FUNC(RemoveDotSegmentsAbsolute)(URI_TYPE(Uri) * uri,
468469

469470
unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig) {
470471
switch (hexdig) {
471-
case _UT('0'):
472-
case _UT('1'):
473-
case _UT('2'):
474-
case _UT('3'):
475-
case _UT('4'):
476-
case _UT('5'):
477-
case _UT('6'):
478-
case _UT('7'):
479-
case _UT('8'):
480-
case _UT('9'):
472+
case URI_SET_DIGIT(_UT):
481473
return (unsigned char)(9 + hexdig - _UT('9'));
482-
483-
case _UT('a'):
484-
case _UT('b'):
485-
case _UT('c'):
486-
case _UT('d'):
487-
case _UT('e'):
488-
case _UT('f'):
474+
case URI_SET_HEX_LETTER_LOWER(_UT):
489475
return (unsigned char)(15 + hexdig - _UT('f'));
490-
491-
case _UT('A'):
492-
case _UT('B'):
493-
case _UT('C'):
494-
case _UT('D'):
495-
case _UT('E'):
496-
case _UT('F'):
476+
case URI_SET_HEX_LETTER_UPPER(_UT):
497477
return (unsigned char)(15 + hexdig - _UT('F'));
498478

499479
default:

ext/uri/uriparser/src/UriEscape.c

Lines changed: 4 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
# ifndef URI_DOXYGEN
6363
# include <uriparser/Uri.h>
6464
# include "UriCommon.h"
65+
# include "UriSets.h"
6566
# endif
6667

6768
URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, UriBool spaceToPlus,
@@ -108,72 +109,7 @@ URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, const URI_CHAR * inAfter
108109
prevWasCr = URI_FALSE;
109110
break;
110111

111-
case _UT('a'): /* ALPHA */
112-
case _UT('A'):
113-
case _UT('b'):
114-
case _UT('B'):
115-
case _UT('c'):
116-
case _UT('C'):
117-
case _UT('d'):
118-
case _UT('D'):
119-
case _UT('e'):
120-
case _UT('E'):
121-
case _UT('f'):
122-
case _UT('F'):
123-
case _UT('g'):
124-
case _UT('G'):
125-
case _UT('h'):
126-
case _UT('H'):
127-
case _UT('i'):
128-
case _UT('I'):
129-
case _UT('j'):
130-
case _UT('J'):
131-
case _UT('k'):
132-
case _UT('K'):
133-
case _UT('l'):
134-
case _UT('L'):
135-
case _UT('m'):
136-
case _UT('M'):
137-
case _UT('n'):
138-
case _UT('N'):
139-
case _UT('o'):
140-
case _UT('O'):
141-
case _UT('p'):
142-
case _UT('P'):
143-
case _UT('q'):
144-
case _UT('Q'):
145-
case _UT('r'):
146-
case _UT('R'):
147-
case _UT('s'):
148-
case _UT('S'):
149-
case _UT('t'):
150-
case _UT('T'):
151-
case _UT('u'):
152-
case _UT('U'):
153-
case _UT('v'):
154-
case _UT('V'):
155-
case _UT('w'):
156-
case _UT('W'):
157-
case _UT('x'):
158-
case _UT('X'):
159-
case _UT('y'):
160-
case _UT('Y'):
161-
case _UT('z'):
162-
case _UT('Z'):
163-
case _UT('0'): /* DIGIT */
164-
case _UT('1'):
165-
case _UT('2'):
166-
case _UT('3'):
167-
case _UT('4'):
168-
case _UT('5'):
169-
case _UT('6'):
170-
case _UT('7'):
171-
case _UT('8'):
172-
case _UT('9'):
173-
case _UT('-'): /* "-" / "." / "_" / "~" */
174-
case _UT('.'):
175-
case _UT('_'):
176-
case _UT('~'):
112+
case URI_SET_UNRESERVED(_UT):
177113
/* Copy unmodified */
178114
write[0] = read[0];
179115
write++;
@@ -263,51 +199,9 @@ const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, UriBool plusToSpa
263199

264200
case _UT('%'):
265201
switch (read[1]) {
266-
case _UT('0'):
267-
case _UT('1'):
268-
case _UT('2'):
269-
case _UT('3'):
270-
case _UT('4'):
271-
case _UT('5'):
272-
case _UT('6'):
273-
case _UT('7'):
274-
case _UT('8'):
275-
case _UT('9'):
276-
case _UT('a'):
277-
case _UT('b'):
278-
case _UT('c'):
279-
case _UT('d'):
280-
case _UT('e'):
281-
case _UT('f'):
282-
case _UT('A'):
283-
case _UT('B'):
284-
case _UT('C'):
285-
case _UT('D'):
286-
case _UT('E'):
287-
case _UT('F'):
202+
case URI_SET_HEXDIG(_UT):
288203
switch (read[2]) {
289-
case _UT('0'):
290-
case _UT('1'):
291-
case _UT('2'):
292-
case _UT('3'):
293-
case _UT('4'):
294-
case _UT('5'):
295-
case _UT('6'):
296-
case _UT('7'):
297-
case _UT('8'):
298-
case _UT('9'):
299-
case _UT('a'):
300-
case _UT('b'):
301-
case _UT('c'):
302-
case _UT('d'):
303-
case _UT('e'):
304-
case _UT('f'):
305-
case _UT('A'):
306-
case _UT('B'):
307-
case _UT('C'):
308-
case _UT('D'):
309-
case _UT('E'):
310-
case _UT('F'): {
204+
case URI_SET_HEXDIG(_UT): {
311205
/* Percent group found */
312206
const unsigned char left = URI_FUNC(HexdigToInt)(read[1]);
313207
const unsigned char right = URI_FUNC(HexdigToInt)(read[2]);

ext/uri/uriparser/src/UriIp4.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
# include <uriparser/UriIp4.h>
6969
# include "UriIp4Base.h"
7070
# include <uriparser/UriBase.h>
71+
# include "UriSets.h"
7172
# endif
7273

7374
/* Prototypes */
@@ -194,16 +195,7 @@ URI_FUNC(ParseDecOctetOne)(UriIp4Parser * parser, const URI_CHAR * first,
194195
}
195196

196197
switch (*first) {
197-
case _UT('0'):
198-
case _UT('1'):
199-
case _UT('2'):
200-
case _UT('3'):
201-
case _UT('4'):
202-
case _UT('5'):
203-
case _UT('6'):
204-
case _UT('7'):
205-
case _UT('8'):
206-
case _UT('9'):
198+
case URI_SET_DIGIT(_UT):
207199
uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9')));
208200
return (const URI_CHAR *)URI_FUNC(ParseDecOctetThree)(parser, first + 1,
209201
afterLast);
@@ -272,16 +264,7 @@ URI_FUNC(ParseDecOctetThree)(UriIp4Parser * parser, const URI_CHAR * first,
272264
}
273265

274266
switch (*first) {
275-
case _UT('0'):
276-
case _UT('1'):
277-
case _UT('2'):
278-
case _UT('3'):
279-
case _UT('4'):
280-
case _UT('5'):
281-
case _UT('6'):
282-
case _UT('7'):
283-
case _UT('8'):
284-
case _UT('9'):
267+
case URI_SET_DIGIT(_UT):
285268
uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9')));
286269
return first + 1;
287270

0 commit comments

Comments
 (0)