/src/uriparser/src/UriResolve.c
Line | Count | Source |
1 | | /* |
2 | | * uriparser - RFC 3986 URI parsing library |
3 | | * |
4 | | * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> |
5 | | * Copyright (C) 2007, Sebastian Pipping <sebastian@pipping.org> |
6 | | * All rights reserved. |
7 | | * |
8 | | * Redistribution and use in source and binary forms, with or without |
9 | | * modification, are permitted provided that the following conditions |
10 | | * are met: |
11 | | * |
12 | | * 1. Redistributions of source code must retain the above |
13 | | * copyright notice, this list of conditions and the following |
14 | | * disclaimer. |
15 | | * |
16 | | * 2. Redistributions in binary form must reproduce the above |
17 | | * copyright notice, this list of conditions and the following |
18 | | * disclaimer in the documentation and/or other materials |
19 | | * provided with the distribution. |
20 | | * |
21 | | * 3. Neither the name of the copyright holder nor the names of |
22 | | * its contributors may be used to endorse or promote products |
23 | | * derived from this software without specific prior written |
24 | | * permission. |
25 | | * |
26 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
27 | | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
28 | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
29 | | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
30 | | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
31 | | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
32 | | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
33 | | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
34 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
35 | | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
36 | | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
37 | | * OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | | */ |
39 | | |
40 | | /* What encodings are enabled? */ |
41 | | #include <uriparser/UriDefsConfig.h> |
42 | | #if (!defined(URI_PASS_ANSI) && !defined(URI_PASS_UNICODE)) |
43 | | /* Include SELF twice */ |
44 | | # ifdef URI_ENABLE_ANSI |
45 | | # define URI_PASS_ANSI 1 |
46 | | # include "UriResolve.c" |
47 | | # undef URI_PASS_ANSI |
48 | | # endif |
49 | | # ifdef URI_ENABLE_UNICODE |
50 | | # define URI_PASS_UNICODE 1 |
51 | | # include "UriResolve.c" |
52 | | # undef URI_PASS_UNICODE |
53 | | # endif |
54 | | #else |
55 | | # ifdef URI_PASS_ANSI |
56 | | # include <uriparser/UriDefsAnsi.h> |
57 | | # else |
58 | | # include <uriparser/UriDefsUnicode.h> |
59 | | # include <wchar.h> |
60 | | # endif |
61 | | |
62 | | # ifndef URI_DOXYGEN |
63 | | # include <uriparser/Uri.h> |
64 | | # include "UriCommon.h" |
65 | | # include "UriMemory.h" |
66 | | # endif |
67 | | |
68 | | /* Appends a relative URI to an absolute. The last path segment of |
69 | | * the absolute URI is replaced. */ |
70 | | static URI_INLINE UriBool URI_FUNC(MergePath)(URI_TYPE(Uri) * absWork, |
71 | | const URI_TYPE(Uri) * relAppend, |
72 | 75 | UriMemoryManager * memory) { |
73 | 75 | URI_TYPE(PathSegment) * sourceWalker; |
74 | 75 | URI_TYPE(PathSegment) * destPrev; |
75 | 75 | if (relAppend->pathHead == NULL) { |
76 | 0 | return URI_TRUE; |
77 | 0 | } |
78 | | |
79 | | /* Replace last segment ("" if trailing slash) with first of append chain */ |
80 | 75 | if (absWork->pathHead == NULL) { |
81 | 33 | URI_TYPE(PathSegment) * const dup = |
82 | 33 | memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); |
83 | 33 | if (dup == NULL) { |
84 | 0 | return URI_FALSE; /* Raises malloc error */ |
85 | 0 | } |
86 | 33 | dup->next = NULL; |
87 | 33 | absWork->pathHead = dup; |
88 | 33 | absWork->pathTail = dup; |
89 | 33 | } |
90 | 75 | absWork->pathTail->text.first = relAppend->pathHead->text.first; |
91 | 75 | absWork->pathTail->text.afterLast = relAppend->pathHead->text.afterLast; |
92 | | |
93 | | /* Append all the others */ |
94 | 75 | sourceWalker = relAppend->pathHead->next; |
95 | 75 | if (sourceWalker == NULL) { |
96 | 42 | return URI_TRUE; |
97 | 42 | } |
98 | 33 | destPrev = absWork->pathTail; |
99 | | |
100 | 611 | for (;;) { |
101 | 611 | URI_TYPE(PathSegment) * const dup = |
102 | 611 | memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); |
103 | 611 | if (dup == NULL) { |
104 | 0 | destPrev->next = NULL; |
105 | 0 | absWork->pathTail = destPrev; |
106 | 0 | return URI_FALSE; /* Raises malloc error */ |
107 | 0 | } |
108 | 611 | dup->text = sourceWalker->text; |
109 | 611 | destPrev->next = dup; |
110 | | |
111 | 611 | if (sourceWalker->next == NULL) { |
112 | 33 | absWork->pathTail = dup; |
113 | 33 | absWork->pathTail->next = NULL; |
114 | 33 | break; |
115 | 33 | } |
116 | 578 | destPrev = dup; |
117 | 578 | sourceWalker = sourceWalker->next; |
118 | 578 | } |
119 | | |
120 | 33 | return URI_TRUE; |
121 | 33 | } UriResolve.c:uriMergePathA Line | Count | Source | 72 | 75 | UriMemoryManager * memory) { | 73 | 75 | URI_TYPE(PathSegment) * sourceWalker; | 74 | 75 | URI_TYPE(PathSegment) * destPrev; | 75 | 75 | if (relAppend->pathHead == NULL) { | 76 | 0 | return URI_TRUE; | 77 | 0 | } | 78 | | | 79 | | /* Replace last segment ("" if trailing slash) with first of append chain */ | 80 | 75 | if (absWork->pathHead == NULL) { | 81 | 33 | URI_TYPE(PathSegment) * const dup = | 82 | 33 | memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); | 83 | 33 | if (dup == NULL) { | 84 | 0 | return URI_FALSE; /* Raises malloc error */ | 85 | 0 | } | 86 | 33 | dup->next = NULL; | 87 | 33 | absWork->pathHead = dup; | 88 | 33 | absWork->pathTail = dup; | 89 | 33 | } | 90 | 75 | absWork->pathTail->text.first = relAppend->pathHead->text.first; | 91 | 75 | absWork->pathTail->text.afterLast = relAppend->pathHead->text.afterLast; | 92 | | | 93 | | /* Append all the others */ | 94 | 75 | sourceWalker = relAppend->pathHead->next; | 95 | 75 | if (sourceWalker == NULL) { | 96 | 42 | return URI_TRUE; | 97 | 42 | } | 98 | 33 | destPrev = absWork->pathTail; | 99 | | | 100 | 611 | for (;;) { | 101 | 611 | URI_TYPE(PathSegment) * const dup = | 102 | 611 | memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); | 103 | 611 | if (dup == NULL) { | 104 | 0 | destPrev->next = NULL; | 105 | 0 | absWork->pathTail = destPrev; | 106 | 0 | return URI_FALSE; /* Raises malloc error */ | 107 | 0 | } | 108 | 611 | dup->text = sourceWalker->text; | 109 | 611 | destPrev->next = dup; | 110 | | | 111 | 611 | if (sourceWalker->next == NULL) { | 112 | 33 | absWork->pathTail = dup; | 113 | 33 | absWork->pathTail->next = NULL; | 114 | 33 | break; | 115 | 33 | } | 116 | 578 | destPrev = dup; | 117 | 578 | sourceWalker = sourceWalker->next; | 118 | 578 | } | 119 | | | 120 | 33 | return URI_TRUE; | 121 | 33 | } |
Unexecuted instantiation: UriResolve.c:uriMergePathW |
122 | | |
123 | | static int URI_FUNC(ResolveAbsolutePathFlag)(URI_TYPE(Uri) * absWork, |
124 | 7 | UriMemoryManager * memory) { |
125 | 7 | if (absWork == NULL) { |
126 | 0 | return URI_ERROR_NULL; |
127 | 0 | } |
128 | | |
129 | 7 | if (URI_FUNC(HasHost)(absWork) && absWork->absolutePath) { |
130 | | /* Empty segment needed, instead? */ |
131 | 2 | if (absWork->pathHead == NULL) { |
132 | 1 | URI_TYPE(PathSegment) * const segment = |
133 | 1 | memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); |
134 | 1 | if (segment == NULL) { |
135 | 0 | return URI_ERROR_MALLOC; |
136 | 0 | } |
137 | 1 | segment->text.first = URI_FUNC(SafeToPointTo); |
138 | 1 | segment->text.afterLast = URI_FUNC(SafeToPointTo); |
139 | 1 | segment->next = NULL; |
140 | | |
141 | 1 | absWork->pathHead = segment; |
142 | 1 | absWork->pathTail = segment; |
143 | 1 | } |
144 | | |
145 | 2 | absWork->absolutePath = URI_FALSE; |
146 | 2 | } |
147 | | |
148 | 7 | return URI_SUCCESS; |
149 | 7 | } UriResolve.c:uriResolveAbsolutePathFlagA Line | Count | Source | 124 | 7 | UriMemoryManager * memory) { | 125 | 7 | if (absWork == NULL) { | 126 | 0 | return URI_ERROR_NULL; | 127 | 0 | } | 128 | | | 129 | 7 | if (URI_FUNC(HasHost)(absWork) && absWork->absolutePath) { | 130 | | /* Empty segment needed, instead? */ | 131 | 2 | if (absWork->pathHead == NULL) { | 132 | 1 | URI_TYPE(PathSegment) * const segment = | 133 | 1 | memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); | 134 | 1 | if (segment == NULL) { | 135 | 0 | return URI_ERROR_MALLOC; | 136 | 0 | } | 137 | 1 | segment->text.first = URI_FUNC(SafeToPointTo); | 138 | 1 | segment->text.afterLast = URI_FUNC(SafeToPointTo); | 139 | 1 | segment->next = NULL; | 140 | | | 141 | 1 | absWork->pathHead = segment; | 142 | 1 | absWork->pathTail = segment; | 143 | 1 | } | 144 | | | 145 | 2 | absWork->absolutePath = URI_FALSE; | 146 | 2 | } | 147 | | | 148 | 7 | return URI_SUCCESS; | 149 | 7 | } |
Unexecuted instantiation: UriResolve.c:uriResolveAbsolutePathFlagW |
150 | | |
151 | | static int URI_FUNC(AddBaseUriImpl)(URI_TYPE(Uri) * absDest, |
152 | | const URI_TYPE(Uri) * relSource, |
153 | | const URI_TYPE(Uri) * absBase, |
154 | | UriResolutionOptions options, |
155 | 6.59k | UriMemoryManager * memory) { |
156 | 6.59k | UriBool relSourceHasScheme; |
157 | | |
158 | 6.59k | if (absDest == NULL) { |
159 | 0 | return URI_ERROR_NULL; |
160 | 0 | } |
161 | 6.59k | URI_FUNC(ResetUri)(absDest); |
162 | | |
163 | 6.59k | if ((relSource == NULL) || (absBase == NULL)) { |
164 | 0 | return URI_ERROR_NULL; |
165 | 0 | } |
166 | | |
167 | | /* absBase absolute? */ |
168 | 6.59k | if (absBase->scheme.first == NULL) { |
169 | 6.25k | return URI_ERROR_ADDBASE_REL_BASE; |
170 | 6.25k | } |
171 | | |
172 | | /* NOTE: The curly brackets here force deeper indent (and that's all) */ |
173 | 342 | { |
174 | 342 | { |
175 | 342 | { |
176 | | /* clang-format off */ |
177 | | /* [00/32] -- A non-strict parser may ignore a scheme in the reference */ |
178 | | /* [00/32] -- if it is identical to the base URI's scheme. */ |
179 | | /* [00/32] if ((not strict) and (R.scheme == Base.scheme)) then */ |
180 | | /* clang-format on */ |
181 | 342 | relSourceHasScheme = |
182 | 342 | (relSource->scheme.first != NULL) ? URI_TRUE : URI_FALSE; |
183 | 342 | if ((options & URI_RESOLVE_IDENTICAL_SCHEME_COMPAT) |
184 | 0 | && (absBase->scheme.first != NULL) |
185 | 0 | && (relSource->scheme.first != NULL) |
186 | 0 | && (0 |
187 | 0 | == URI_FUNC(CompareRange)(&(absBase->scheme), |
188 | 0 | &(relSource->scheme)))) { |
189 | | /* clang-format off */ |
190 | | /* [00/32] undefine(R.scheme); */ |
191 | | /* clang-format on */ |
192 | 0 | relSourceHasScheme = URI_FALSE; |
193 | | /* clang-format off */ |
194 | | /* [00/32] endif; */ |
195 | | /* clang-format on */ |
196 | 0 | } |
197 | | |
198 | | /* clang-format off */ |
199 | | /* [01/32] if defined(R.scheme) then */ |
200 | | /* clang-format on */ |
201 | 342 | if (relSourceHasScheme) { |
202 | | /* clang-format off */ |
203 | | /* [02/32] T.scheme = R.scheme; */ |
204 | | /* clang-format on */ |
205 | 189 | absDest->scheme = relSource->scheme; |
206 | | /* clang-format off */ |
207 | | /* [03/32] T.authority = R.authority; */ |
208 | | /* clang-format on */ |
209 | 189 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { |
210 | 0 | return URI_ERROR_MALLOC; |
211 | 0 | } |
212 | | /* clang-format off */ |
213 | | /* [04/32] T.path = remove_dot_segments(R.path); */ |
214 | | /* clang-format on */ |
215 | 189 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { |
216 | 0 | return URI_ERROR_MALLOC; |
217 | 0 | } |
218 | 189 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { |
219 | 0 | return URI_ERROR_MALLOC; |
220 | 0 | } |
221 | | /* clang-format off */ |
222 | | /* [05/32] T.query = R.query; */ |
223 | | /* clang-format on */ |
224 | 189 | absDest->query = relSource->query; |
225 | | /* clang-format off */ |
226 | | /* [06/32] else */ |
227 | | /* clang-format on */ |
228 | 189 | } else { |
229 | | /* clang-format off */ |
230 | | /* [07/32] if defined(R.authority) then */ |
231 | | /* clang-format on */ |
232 | 153 | if (URI_FUNC(HasHost)(relSource)) { |
233 | | /* clang-format off */ |
234 | | /* [08/32] T.authority = R.authority; */ |
235 | | /* clang-format on */ |
236 | 6 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { |
237 | 0 | return URI_ERROR_MALLOC; |
238 | 0 | } |
239 | | /* clang-format off */ |
240 | | /* [09/32] T.path = remove_dot_segments(R.path); */ |
241 | | /* clang-format on */ |
242 | 6 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { |
243 | 0 | return URI_ERROR_MALLOC; |
244 | 0 | } |
245 | 6 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { |
246 | 0 | return URI_ERROR_MALLOC; |
247 | 0 | } |
248 | | /* clang-format off */ |
249 | | /* [10/32] T.query = R.query; */ |
250 | | /* clang-format on */ |
251 | 6 | absDest->query = relSource->query; |
252 | | /* clang-format off */ |
253 | | /* [11/32] else */ |
254 | | /* clang-format on */ |
255 | 147 | } else { |
256 | | /* clang-format off */ |
257 | | /* [28/32] T.authority = Base.authority; */ |
258 | | /* clang-format on */ |
259 | 147 | if (!URI_FUNC(CopyAuthority)(absDest, absBase, memory)) { |
260 | 0 | return URI_ERROR_MALLOC; |
261 | 0 | } |
262 | | /* clang-format off */ |
263 | | /* [12/32] if (R.path == "") then */ |
264 | | /* clang-format on */ |
265 | 147 | if (relSource->pathHead == NULL && !relSource->absolutePath) { |
266 | | /* clang-format off */ |
267 | | /* [13/32] T.path = Base.path; */ |
268 | | /* clang-format on */ |
269 | 65 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { |
270 | 0 | return URI_ERROR_MALLOC; |
271 | 0 | } |
272 | | /* clang-format off */ |
273 | | /* [14/32] if defined(R.query) then */ |
274 | | /* clang-format on */ |
275 | 65 | if (relSource->query.first != NULL) { |
276 | | /* clang-format off */ |
277 | | /* [15/32] T.query = R.query; */ |
278 | | /* clang-format on */ |
279 | 1 | absDest->query = relSource->query; |
280 | | /* clang-format off */ |
281 | | /* [16/32] else */ |
282 | | /* clang-format on */ |
283 | 64 | } else { |
284 | | /* clang-format off */ |
285 | | /* [17/32] T.query = Base.query; */ |
286 | | /* clang-format on */ |
287 | 64 | absDest->query = absBase->query; |
288 | | /* clang-format off */ |
289 | | /* [18/32] endif; */ |
290 | | /* clang-format on */ |
291 | 64 | } |
292 | | /* clang-format off */ |
293 | | /* [19/32] else */ |
294 | | /* clang-format on */ |
295 | 82 | } else { |
296 | | /* clang-format off */ |
297 | | /* [20/32] if (R.path starts-with "/") then */ |
298 | | /* clang-format on */ |
299 | 82 | if (relSource->absolutePath) { |
300 | 7 | int res; |
301 | | /* clang-format off */ |
302 | | /* [21/32] T.path = remove_dot_segments(R.path); */ |
303 | | /* clang-format on */ |
304 | 7 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { |
305 | 0 | return URI_ERROR_MALLOC; |
306 | 0 | } |
307 | 7 | res = URI_FUNC(ResolveAbsolutePathFlag)(absDest, memory); |
308 | 7 | if (res != URI_SUCCESS) { |
309 | 0 | return res; |
310 | 0 | } |
311 | 7 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, |
312 | 7 | memory)) { |
313 | 0 | return URI_ERROR_MALLOC; |
314 | 0 | } |
315 | | /* clang-format off */ |
316 | | /* [22/32] else */ |
317 | | /* clang-format on */ |
318 | 75 | } else { |
319 | | /* clang-format off */ |
320 | | /* [23/32] T.path = merge(Base.path, R.path); */ |
321 | | /* clang-format on */ |
322 | 75 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { |
323 | 0 | return URI_ERROR_MALLOC; |
324 | 0 | } |
325 | 75 | if (!URI_FUNC(MergePath)(absDest, relSource, memory)) { |
326 | 0 | return URI_ERROR_MALLOC; |
327 | 0 | } |
328 | | /* clang-format off */ |
329 | | /* [24/32] T.path = remove_dot_segments(T.path); */ |
330 | | /* clang-format on */ |
331 | 75 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, |
332 | 75 | memory)) { |
333 | 0 | return URI_ERROR_MALLOC; |
334 | 0 | } |
335 | | |
336 | 75 | if (!URI_FUNC(FixAmbiguity)(absDest, memory)) { |
337 | 0 | return URI_ERROR_MALLOC; |
338 | 0 | } |
339 | | /* clang-format off */ |
340 | | /* [25/32] endif; */ |
341 | 75 | } |
342 | | /* clang-format off */ |
343 | | /* [26/32] T.query = R.query; */ |
344 | | /* clang-format on */ |
345 | 82 | absDest->query = relSource->query; |
346 | | /* clang-format off */ |
347 | | /* [27/32] endif; */ |
348 | | /* clang-format on */ |
349 | 82 | } |
350 | 147 | URI_FUNC(FixEmptyTrailSegment)(absDest, memory); |
351 | | /* clang-format off */ |
352 | | /* [29/32] endif; */ |
353 | | /* clang-format on */ |
354 | 147 | } |
355 | | /* clang-format off */ |
356 | | /* [30/32] T.scheme = Base.scheme; */ |
357 | | /* clang-format on */ |
358 | 153 | absDest->scheme = absBase->scheme; |
359 | | /* clang-format off */ |
360 | | /* [31/32] endif; */ |
361 | | /* clang-format on */ |
362 | 153 | } |
363 | | /* clang-format off */ |
364 | | /* [32/32] T.fragment = R.fragment; */ |
365 | | /* clang-format on */ |
366 | 342 | absDest->fragment = relSource->fragment; |
367 | 342 | } |
368 | 342 | } |
369 | 342 | } |
370 | 342 | return URI_SUCCESS; |
371 | 342 | } UriResolve.c:uriAddBaseUriImplA Line | Count | Source | 155 | 6.59k | UriMemoryManager * memory) { | 156 | 6.59k | UriBool relSourceHasScheme; | 157 | | | 158 | 6.59k | if (absDest == NULL) { | 159 | 0 | return URI_ERROR_NULL; | 160 | 0 | } | 161 | 6.59k | URI_FUNC(ResetUri)(absDest); | 162 | | | 163 | 6.59k | if ((relSource == NULL) || (absBase == NULL)) { | 164 | 0 | return URI_ERROR_NULL; | 165 | 0 | } | 166 | | | 167 | | /* absBase absolute? */ | 168 | 6.59k | if (absBase->scheme.first == NULL) { | 169 | 6.25k | return URI_ERROR_ADDBASE_REL_BASE; | 170 | 6.25k | } | 171 | | | 172 | | /* NOTE: The curly brackets here force deeper indent (and that's all) */ | 173 | 342 | { | 174 | 342 | { | 175 | 342 | { | 176 | | /* clang-format off */ | 177 | | /* [00/32] -- A non-strict parser may ignore a scheme in the reference */ | 178 | | /* [00/32] -- if it is identical to the base URI's scheme. */ | 179 | | /* [00/32] if ((not strict) and (R.scheme == Base.scheme)) then */ | 180 | | /* clang-format on */ | 181 | 342 | relSourceHasScheme = | 182 | 342 | (relSource->scheme.first != NULL) ? URI_TRUE : URI_FALSE; | 183 | 342 | if ((options & URI_RESOLVE_IDENTICAL_SCHEME_COMPAT) | 184 | 0 | && (absBase->scheme.first != NULL) | 185 | 0 | && (relSource->scheme.first != NULL) | 186 | 0 | && (0 | 187 | 0 | == URI_FUNC(CompareRange)(&(absBase->scheme), | 188 | 0 | &(relSource->scheme)))) { | 189 | | /* clang-format off */ | 190 | | /* [00/32] undefine(R.scheme); */ | 191 | | /* clang-format on */ | 192 | 0 | relSourceHasScheme = URI_FALSE; | 193 | | /* clang-format off */ | 194 | | /* [00/32] endif; */ | 195 | | /* clang-format on */ | 196 | 0 | } | 197 | | | 198 | | /* clang-format off */ | 199 | | /* [01/32] if defined(R.scheme) then */ | 200 | | /* clang-format on */ | 201 | 342 | if (relSourceHasScheme) { | 202 | | /* clang-format off */ | 203 | | /* [02/32] T.scheme = R.scheme; */ | 204 | | /* clang-format on */ | 205 | 189 | absDest->scheme = relSource->scheme; | 206 | | /* clang-format off */ | 207 | | /* [03/32] T.authority = R.authority; */ | 208 | | /* clang-format on */ | 209 | 189 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { | 210 | 0 | return URI_ERROR_MALLOC; | 211 | 0 | } | 212 | | /* clang-format off */ | 213 | | /* [04/32] T.path = remove_dot_segments(R.path); */ | 214 | | /* clang-format on */ | 215 | 189 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { | 216 | 0 | return URI_ERROR_MALLOC; | 217 | 0 | } | 218 | 189 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { | 219 | 0 | return URI_ERROR_MALLOC; | 220 | 0 | } | 221 | | /* clang-format off */ | 222 | | /* [05/32] T.query = R.query; */ | 223 | | /* clang-format on */ | 224 | 189 | absDest->query = relSource->query; | 225 | | /* clang-format off */ | 226 | | /* [06/32] else */ | 227 | | /* clang-format on */ | 228 | 189 | } else { | 229 | | /* clang-format off */ | 230 | | /* [07/32] if defined(R.authority) then */ | 231 | | /* clang-format on */ | 232 | 153 | if (URI_FUNC(HasHost)(relSource)) { | 233 | | /* clang-format off */ | 234 | | /* [08/32] T.authority = R.authority; */ | 235 | | /* clang-format on */ | 236 | 6 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { | 237 | 0 | return URI_ERROR_MALLOC; | 238 | 0 | } | 239 | | /* clang-format off */ | 240 | | /* [09/32] T.path = remove_dot_segments(R.path); */ | 241 | | /* clang-format on */ | 242 | 6 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { | 243 | 0 | return URI_ERROR_MALLOC; | 244 | 0 | } | 245 | 6 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { | 246 | 0 | return URI_ERROR_MALLOC; | 247 | 0 | } | 248 | | /* clang-format off */ | 249 | | /* [10/32] T.query = R.query; */ | 250 | | /* clang-format on */ | 251 | 6 | absDest->query = relSource->query; | 252 | | /* clang-format off */ | 253 | | /* [11/32] else */ | 254 | | /* clang-format on */ | 255 | 147 | } else { | 256 | | /* clang-format off */ | 257 | | /* [28/32] T.authority = Base.authority; */ | 258 | | /* clang-format on */ | 259 | 147 | if (!URI_FUNC(CopyAuthority)(absDest, absBase, memory)) { | 260 | 0 | return URI_ERROR_MALLOC; | 261 | 0 | } | 262 | | /* clang-format off */ | 263 | | /* [12/32] if (R.path == "") then */ | 264 | | /* clang-format on */ | 265 | 147 | if (relSource->pathHead == NULL && !relSource->absolutePath) { | 266 | | /* clang-format off */ | 267 | | /* [13/32] T.path = Base.path; */ | 268 | | /* clang-format on */ | 269 | 65 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { | 270 | 0 | return URI_ERROR_MALLOC; | 271 | 0 | } | 272 | | /* clang-format off */ | 273 | | /* [14/32] if defined(R.query) then */ | 274 | | /* clang-format on */ | 275 | 65 | if (relSource->query.first != NULL) { | 276 | | /* clang-format off */ | 277 | | /* [15/32] T.query = R.query; */ | 278 | | /* clang-format on */ | 279 | 1 | absDest->query = relSource->query; | 280 | | /* clang-format off */ | 281 | | /* [16/32] else */ | 282 | | /* clang-format on */ | 283 | 64 | } else { | 284 | | /* clang-format off */ | 285 | | /* [17/32] T.query = Base.query; */ | 286 | | /* clang-format on */ | 287 | 64 | absDest->query = absBase->query; | 288 | | /* clang-format off */ | 289 | | /* [18/32] endif; */ | 290 | | /* clang-format on */ | 291 | 64 | } | 292 | | /* clang-format off */ | 293 | | /* [19/32] else */ | 294 | | /* clang-format on */ | 295 | 82 | } else { | 296 | | /* clang-format off */ | 297 | | /* [20/32] if (R.path starts-with "/") then */ | 298 | | /* clang-format on */ | 299 | 82 | if (relSource->absolutePath) { | 300 | 7 | int res; | 301 | | /* clang-format off */ | 302 | | /* [21/32] T.path = remove_dot_segments(R.path); */ | 303 | | /* clang-format on */ | 304 | 7 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { | 305 | 0 | return URI_ERROR_MALLOC; | 306 | 0 | } | 307 | 7 | res = URI_FUNC(ResolveAbsolutePathFlag)(absDest, memory); | 308 | 7 | if (res != URI_SUCCESS) { | 309 | 0 | return res; | 310 | 0 | } | 311 | 7 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, | 312 | 7 | memory)) { | 313 | 0 | return URI_ERROR_MALLOC; | 314 | 0 | } | 315 | | /* clang-format off */ | 316 | | /* [22/32] else */ | 317 | | /* clang-format on */ | 318 | 75 | } else { | 319 | | /* clang-format off */ | 320 | | /* [23/32] T.path = merge(Base.path, R.path); */ | 321 | | /* clang-format on */ | 322 | 75 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { | 323 | 0 | return URI_ERROR_MALLOC; | 324 | 0 | } | 325 | 75 | if (!URI_FUNC(MergePath)(absDest, relSource, memory)) { | 326 | 0 | return URI_ERROR_MALLOC; | 327 | 0 | } | 328 | | /* clang-format off */ | 329 | | /* [24/32] T.path = remove_dot_segments(T.path); */ | 330 | | /* clang-format on */ | 331 | 75 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, | 332 | 75 | memory)) { | 333 | 0 | return URI_ERROR_MALLOC; | 334 | 0 | } | 335 | | | 336 | 75 | if (!URI_FUNC(FixAmbiguity)(absDest, memory)) { | 337 | 0 | return URI_ERROR_MALLOC; | 338 | 0 | } | 339 | | /* clang-format off */ | 340 | | /* [25/32] endif; */ | 341 | 75 | } | 342 | | /* clang-format off */ | 343 | | /* [26/32] T.query = R.query; */ | 344 | | /* clang-format on */ | 345 | 82 | absDest->query = relSource->query; | 346 | | /* clang-format off */ | 347 | | /* [27/32] endif; */ | 348 | | /* clang-format on */ | 349 | 82 | } | 350 | 147 | URI_FUNC(FixEmptyTrailSegment)(absDest, memory); | 351 | | /* clang-format off */ | 352 | | /* [29/32] endif; */ | 353 | | /* clang-format on */ | 354 | 147 | } | 355 | | /* clang-format off */ | 356 | | /* [30/32] T.scheme = Base.scheme; */ | 357 | | /* clang-format on */ | 358 | 153 | absDest->scheme = absBase->scheme; | 359 | | /* clang-format off */ | 360 | | /* [31/32] endif; */ | 361 | | /* clang-format on */ | 362 | 153 | } | 363 | | /* clang-format off */ | 364 | | /* [32/32] T.fragment = R.fragment; */ | 365 | | /* clang-format on */ | 366 | 342 | absDest->fragment = relSource->fragment; | 367 | 342 | } | 368 | 342 | } | 369 | 342 | } | 370 | 342 | return URI_SUCCESS; | 371 | 342 | } |
Unexecuted instantiation: UriResolve.c:uriAddBaseUriImplW |
372 | | |
373 | | int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absDest, const URI_TYPE(Uri) * relSource, |
374 | 6.59k | const URI_TYPE(Uri) * absBase) { |
375 | 6.59k | const UriResolutionOptions options = URI_RESOLVE_STRICTLY; |
376 | 6.59k | return URI_FUNC(AddBaseUriEx)(absDest, relSource, absBase, options); |
377 | 6.59k | } Line | Count | Source | 374 | 6.59k | const URI_TYPE(Uri) * absBase) { | 375 | 6.59k | const UriResolutionOptions options = URI_RESOLVE_STRICTLY; | 376 | 6.59k | return URI_FUNC(AddBaseUriEx)(absDest, relSource, absBase, options); | 377 | 6.59k | } |
Unexecuted instantiation: uriAddBaseUriW |
378 | | |
379 | | int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absDest, const URI_TYPE(Uri) * relSource, |
380 | 6.59k | const URI_TYPE(Uri) * absBase, UriResolutionOptions options) { |
381 | 6.59k | return URI_FUNC(AddBaseUriExMm)(absDest, relSource, absBase, options, NULL); |
382 | 6.59k | } Line | Count | Source | 380 | 6.59k | const URI_TYPE(Uri) * absBase, UriResolutionOptions options) { | 381 | 6.59k | return URI_FUNC(AddBaseUriExMm)(absDest, relSource, absBase, options, NULL); | 382 | 6.59k | } |
Unexecuted instantiation: uriAddBaseUriExW |
383 | | |
384 | | int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absDest, const URI_TYPE(Uri) * relSource, |
385 | | const URI_TYPE(Uri) * absBase, UriResolutionOptions options, |
386 | 6.59k | UriMemoryManager * memory) { |
387 | 6.59k | int res; |
388 | | |
389 | 6.59k | URI_CHECK_MEMORY_MANAGER(memory); /* may return */ |
390 | | |
391 | 6.59k | res = URI_FUNC(AddBaseUriImpl)(absDest, relSource, absBase, options, memory); |
392 | 6.59k | if ((res != URI_SUCCESS) && (absDest != NULL)) { |
393 | 6.25k | URI_FUNC(FreeUriMembersMm)(absDest, memory); |
394 | 6.25k | } |
395 | 6.59k | return res; |
396 | 6.59k | } Line | Count | Source | 386 | 6.59k | UriMemoryManager * memory) { | 387 | 6.59k | int res; | 388 | | | 389 | 6.59k | URI_CHECK_MEMORY_MANAGER(memory); /* may return */ | 390 | | | 391 | 6.59k | res = URI_FUNC(AddBaseUriImpl)(absDest, relSource, absBase, options, memory); | 392 | 6.59k | if ((res != URI_SUCCESS) && (absDest != NULL)) { | 393 | 6.25k | URI_FUNC(FreeUriMembersMm)(absDest, memory); | 394 | 6.25k | } | 395 | 6.59k | return res; | 396 | 6.59k | } |
Unexecuted instantiation: uriAddBaseUriExMmW |
397 | | |
398 | | #endif |