/src/uriparser/src/UriResolve.c
Line | Count | Source (jump to first uncovered line) |
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 | | |
63 | | |
64 | | #ifndef URI_DOXYGEN |
65 | | # include <uriparser/Uri.h> |
66 | | # include "UriCommon.h" |
67 | | # include "UriMemory.h" |
68 | | #endif |
69 | | |
70 | | |
71 | | |
72 | | /* Appends a relative URI to an absolute. The last path segment of |
73 | | * the absolute URI is replaced. */ |
74 | | static URI_INLINE UriBool URI_FUNC(MergePath)(URI_TYPE(Uri) * absWork, |
75 | 72 | const URI_TYPE(Uri) * relAppend, UriMemoryManager * memory) { |
76 | 72 | URI_TYPE(PathSegment) * sourceWalker; |
77 | 72 | URI_TYPE(PathSegment) * destPrev; |
78 | 72 | if (relAppend->pathHead == NULL) { |
79 | 0 | return URI_TRUE; |
80 | 0 | } |
81 | | |
82 | | /* Replace last segment ("" if trailing slash) with first of append chain */ |
83 | 72 | if (absWork->pathHead == NULL) { |
84 | 31 | URI_TYPE(PathSegment) * const dup = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); |
85 | 31 | if (dup == NULL) { |
86 | 0 | return URI_FALSE; /* Raises malloc error */ |
87 | 0 | } |
88 | 31 | dup->next = NULL; |
89 | 31 | absWork->pathHead = dup; |
90 | 31 | absWork->pathTail = dup; |
91 | 31 | } |
92 | 72 | absWork->pathTail->text.first = relAppend->pathHead->text.first; |
93 | 72 | absWork->pathTail->text.afterLast = relAppend->pathHead->text.afterLast; |
94 | | |
95 | | /* Append all the others */ |
96 | 72 | sourceWalker = relAppend->pathHead->next; |
97 | 72 | if (sourceWalker == NULL) { |
98 | 39 | return URI_TRUE; |
99 | 39 | } |
100 | 33 | destPrev = absWork->pathTail; |
101 | | |
102 | 350 | for (;;) { |
103 | 350 | URI_TYPE(PathSegment) * const dup = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); |
104 | 350 | if (dup == NULL) { |
105 | 0 | destPrev->next = NULL; |
106 | 0 | absWork->pathTail = destPrev; |
107 | 0 | return URI_FALSE; /* Raises malloc error */ |
108 | 0 | } |
109 | 350 | dup->text = sourceWalker->text; |
110 | 350 | destPrev->next = dup; |
111 | | |
112 | 350 | if (sourceWalker->next == NULL) { |
113 | 33 | absWork->pathTail = dup; |
114 | 33 | absWork->pathTail->next = NULL; |
115 | 33 | break; |
116 | 33 | } |
117 | 317 | destPrev = dup; |
118 | 317 | sourceWalker = sourceWalker->next; |
119 | 317 | } |
120 | | |
121 | 33 | return URI_TRUE; |
122 | 33 | } UriResolve.c:uriMergePathA Line | Count | Source | 75 | 72 | const URI_TYPE(Uri) * relAppend, UriMemoryManager * memory) { | 76 | 72 | URI_TYPE(PathSegment) * sourceWalker; | 77 | 72 | URI_TYPE(PathSegment) * destPrev; | 78 | 72 | if (relAppend->pathHead == NULL) { | 79 | 0 | return URI_TRUE; | 80 | 0 | } | 81 | | | 82 | | /* Replace last segment ("" if trailing slash) with first of append chain */ | 83 | 72 | if (absWork->pathHead == NULL) { | 84 | 31 | URI_TYPE(PathSegment) * const dup = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); | 85 | 31 | if (dup == NULL) { | 86 | 0 | return URI_FALSE; /* Raises malloc error */ | 87 | 0 | } | 88 | 31 | dup->next = NULL; | 89 | 31 | absWork->pathHead = dup; | 90 | 31 | absWork->pathTail = dup; | 91 | 31 | } | 92 | 72 | absWork->pathTail->text.first = relAppend->pathHead->text.first; | 93 | 72 | absWork->pathTail->text.afterLast = relAppend->pathHead->text.afterLast; | 94 | | | 95 | | /* Append all the others */ | 96 | 72 | sourceWalker = relAppend->pathHead->next; | 97 | 72 | if (sourceWalker == NULL) { | 98 | 39 | return URI_TRUE; | 99 | 39 | } | 100 | 33 | destPrev = absWork->pathTail; | 101 | | | 102 | 350 | for (;;) { | 103 | 350 | URI_TYPE(PathSegment) * const dup = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); | 104 | 350 | if (dup == NULL) { | 105 | 0 | destPrev->next = NULL; | 106 | 0 | absWork->pathTail = destPrev; | 107 | 0 | return URI_FALSE; /* Raises malloc error */ | 108 | 0 | } | 109 | 350 | dup->text = sourceWalker->text; | 110 | 350 | destPrev->next = dup; | 111 | | | 112 | 350 | if (sourceWalker->next == NULL) { | 113 | 33 | absWork->pathTail = dup; | 114 | 33 | absWork->pathTail->next = NULL; | 115 | 33 | break; | 116 | 33 | } | 117 | 317 | destPrev = dup; | 118 | 317 | sourceWalker = sourceWalker->next; | 119 | 317 | } | 120 | | | 121 | 33 | return URI_TRUE; | 122 | 33 | } |
Unexecuted instantiation: UriResolve.c:uriMergePathW |
123 | | |
124 | | |
125 | | static int URI_FUNC(ResolveAbsolutePathFlag)(URI_TYPE(Uri) * absWork, |
126 | 6 | UriMemoryManager * memory) { |
127 | 6 | if (absWork == NULL) { |
128 | 0 | return URI_ERROR_NULL; |
129 | 0 | } |
130 | | |
131 | 6 | if (URI_FUNC(HasHost)(absWork) && absWork->absolutePath) { |
132 | | /* Empty segment needed, instead? */ |
133 | 2 | if (absWork->pathHead == NULL) { |
134 | 1 | URI_TYPE(PathSegment) * const segment = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); |
135 | 1 | if (segment == NULL) { |
136 | 0 | return URI_ERROR_MALLOC; |
137 | 0 | } |
138 | 1 | segment->text.first = URI_FUNC(SafeToPointTo); |
139 | 1 | segment->text.afterLast = URI_FUNC(SafeToPointTo); |
140 | 1 | segment->next = NULL; |
141 | | |
142 | 1 | absWork->pathHead = segment; |
143 | 1 | absWork->pathTail = segment; |
144 | 1 | } |
145 | | |
146 | 2 | absWork->absolutePath = URI_FALSE; |
147 | 2 | } |
148 | | |
149 | 6 | return URI_SUCCESS; |
150 | 6 | } UriResolve.c:uriResolveAbsolutePathFlagA Line | Count | Source | 126 | 6 | UriMemoryManager * memory) { | 127 | 6 | if (absWork == NULL) { | 128 | 0 | return URI_ERROR_NULL; | 129 | 0 | } | 130 | | | 131 | 6 | if (URI_FUNC(HasHost)(absWork) && absWork->absolutePath) { | 132 | | /* Empty segment needed, instead? */ | 133 | 2 | if (absWork->pathHead == NULL) { | 134 | 1 | URI_TYPE(PathSegment) * const segment = memory->malloc(memory, sizeof(URI_TYPE(PathSegment))); | 135 | 1 | if (segment == NULL) { | 136 | 0 | return URI_ERROR_MALLOC; | 137 | 0 | } | 138 | 1 | segment->text.first = URI_FUNC(SafeToPointTo); | 139 | 1 | segment->text.afterLast = URI_FUNC(SafeToPointTo); | 140 | 1 | segment->next = NULL; | 141 | | | 142 | 1 | absWork->pathHead = segment; | 143 | 1 | absWork->pathTail = segment; | 144 | 1 | } | 145 | | | 146 | 2 | absWork->absolutePath = URI_FALSE; | 147 | 2 | } | 148 | | | 149 | 6 | return URI_SUCCESS; | 150 | 6 | } |
Unexecuted instantiation: UriResolve.c:uriResolveAbsolutePathFlagW |
151 | | |
152 | | |
153 | | static int URI_FUNC(AddBaseUriImpl)(URI_TYPE(Uri) * absDest, |
154 | | const URI_TYPE(Uri) * relSource, |
155 | | const URI_TYPE(Uri) * absBase, |
156 | 7.04k | UriResolutionOptions options, UriMemoryManager * memory) { |
157 | 7.04k | UriBool relSourceHasScheme; |
158 | | |
159 | 7.04k | if (absDest == NULL) { |
160 | 0 | return URI_ERROR_NULL; |
161 | 0 | } |
162 | 7.04k | URI_FUNC(ResetUri)(absDest); |
163 | | |
164 | 7.04k | if ((relSource == NULL) || (absBase == NULL)) { |
165 | 0 | return URI_ERROR_NULL; |
166 | 0 | } |
167 | | |
168 | | /* absBase absolute? */ |
169 | 7.04k | if (absBase->scheme.first == NULL) { |
170 | 6.69k | return URI_ERROR_ADDBASE_REL_BASE; |
171 | 6.69k | } |
172 | | |
173 | | /* [00/32] -- A non-strict parser may ignore a scheme in the reference */ |
174 | | /* [00/32] -- if it is identical to the base URI's scheme. */ |
175 | | /* [00/32] if ((not strict) and (R.scheme == Base.scheme)) then */ |
176 | 354 | relSourceHasScheme = (relSource->scheme.first != NULL) ? URI_TRUE : URI_FALSE; |
177 | 354 | if ((options & URI_RESOLVE_IDENTICAL_SCHEME_COMPAT) |
178 | 354 | && (absBase->scheme.first != NULL) |
179 | 354 | && (relSource->scheme.first != NULL) |
180 | 354 | && (0 == URI_FUNC(CompareRange)(&(absBase->scheme), &(relSource->scheme)))) { |
181 | | /* [00/32] undefine(R.scheme); */ |
182 | 0 | relSourceHasScheme = URI_FALSE; |
183 | | /* [00/32] endif; */ |
184 | 0 | } |
185 | | |
186 | | /* [01/32] if defined(R.scheme) then */ |
187 | 354 | if (relSourceHasScheme) { |
188 | | /* [02/32] T.scheme = R.scheme; */ |
189 | 201 | absDest->scheme = relSource->scheme; |
190 | | /* [03/32] T.authority = R.authority; */ |
191 | 201 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { |
192 | 0 | return URI_ERROR_MALLOC; |
193 | 0 | } |
194 | | /* [04/32] T.path = remove_dot_segments(R.path); */ |
195 | 201 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { |
196 | 0 | return URI_ERROR_MALLOC; |
197 | 0 | } |
198 | 201 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { |
199 | 0 | return URI_ERROR_MALLOC; |
200 | 0 | } |
201 | | /* [05/32] T.query = R.query; */ |
202 | 201 | absDest->query = relSource->query; |
203 | | /* [06/32] else */ |
204 | 201 | } else { |
205 | | /* [07/32] if defined(R.authority) then */ |
206 | 153 | if (URI_FUNC(HasHost)(relSource)) { |
207 | | /* [08/32] T.authority = R.authority; */ |
208 | 3 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { |
209 | 0 | return URI_ERROR_MALLOC; |
210 | 0 | } |
211 | | /* [09/32] T.path = remove_dot_segments(R.path); */ |
212 | 3 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { |
213 | 0 | return URI_ERROR_MALLOC; |
214 | 0 | } |
215 | 3 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { |
216 | 0 | return URI_ERROR_MALLOC; |
217 | 0 | } |
218 | | /* [10/32] T.query = R.query; */ |
219 | 3 | absDest->query = relSource->query; |
220 | | /* [11/32] else */ |
221 | 150 | } else { |
222 | | /* [28/32] T.authority = Base.authority; */ |
223 | 150 | if (!URI_FUNC(CopyAuthority)(absDest, absBase, memory)) { |
224 | 0 | return URI_ERROR_MALLOC; |
225 | 0 | } |
226 | | /* [12/32] if (R.path == "") then */ |
227 | 150 | if (relSource->pathHead == NULL && !relSource->absolutePath) { |
228 | | /* [13/32] T.path = Base.path; */ |
229 | 72 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { |
230 | 0 | return URI_ERROR_MALLOC; |
231 | 0 | } |
232 | | /* [14/32] if defined(R.query) then */ |
233 | 72 | if (relSource->query.first != NULL) { |
234 | | /* [15/32] T.query = R.query; */ |
235 | 1 | absDest->query = relSource->query; |
236 | | /* [16/32] else */ |
237 | 71 | } else { |
238 | | /* [17/32] T.query = Base.query; */ |
239 | 71 | absDest->query = absBase->query; |
240 | | /* [18/32] endif; */ |
241 | 71 | } |
242 | | /* [19/32] else */ |
243 | 78 | } else { |
244 | | /* [20/32] if (R.path starts-with "/") then */ |
245 | 78 | if (relSource->absolutePath) { |
246 | 6 | int res; |
247 | | /* [21/32] T.path = remove_dot_segments(R.path); */ |
248 | 6 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { |
249 | 0 | return URI_ERROR_MALLOC; |
250 | 0 | } |
251 | 6 | res = URI_FUNC(ResolveAbsolutePathFlag)(absDest, memory); |
252 | 6 | if (res != URI_SUCCESS) { |
253 | 0 | return res; |
254 | 0 | } |
255 | 6 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { |
256 | 0 | return URI_ERROR_MALLOC; |
257 | 0 | } |
258 | | /* [22/32] else */ |
259 | 72 | } else { |
260 | | /* [23/32] T.path = merge(Base.path, R.path); */ |
261 | 72 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { |
262 | 0 | return URI_ERROR_MALLOC; |
263 | 0 | } |
264 | 72 | if (!URI_FUNC(MergePath)(absDest, relSource, memory)) { |
265 | 0 | return URI_ERROR_MALLOC; |
266 | 0 | } |
267 | | /* [24/32] T.path = remove_dot_segments(T.path); */ |
268 | 72 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { |
269 | 0 | return URI_ERROR_MALLOC; |
270 | 0 | } |
271 | | |
272 | 72 | if (!URI_FUNC(FixAmbiguity)(absDest, memory)) { |
273 | 0 | return URI_ERROR_MALLOC; |
274 | 0 | } |
275 | | /* [25/32] endif; */ |
276 | 72 | } |
277 | | /* [26/32] T.query = R.query; */ |
278 | 78 | absDest->query = relSource->query; |
279 | | /* [27/32] endif; */ |
280 | 78 | } |
281 | 150 | URI_FUNC(FixEmptyTrailSegment)(absDest, memory); |
282 | | /* [29/32] endif; */ |
283 | 150 | } |
284 | | /* [30/32] T.scheme = Base.scheme; */ |
285 | 153 | absDest->scheme = absBase->scheme; |
286 | | /* [31/32] endif; */ |
287 | 153 | } |
288 | | /* [32/32] T.fragment = R.fragment; */ |
289 | 354 | absDest->fragment = relSource->fragment; |
290 | | |
291 | 354 | return URI_SUCCESS; |
292 | | |
293 | 354 | } UriResolve.c:uriAddBaseUriImplA Line | Count | Source | 156 | 7.04k | UriResolutionOptions options, UriMemoryManager * memory) { | 157 | 7.04k | UriBool relSourceHasScheme; | 158 | | | 159 | 7.04k | if (absDest == NULL) { | 160 | 0 | return URI_ERROR_NULL; | 161 | 0 | } | 162 | 7.04k | URI_FUNC(ResetUri)(absDest); | 163 | | | 164 | 7.04k | if ((relSource == NULL) || (absBase == NULL)) { | 165 | 0 | return URI_ERROR_NULL; | 166 | 0 | } | 167 | | | 168 | | /* absBase absolute? */ | 169 | 7.04k | if (absBase->scheme.first == NULL) { | 170 | 6.69k | return URI_ERROR_ADDBASE_REL_BASE; | 171 | 6.69k | } | 172 | | | 173 | | /* [00/32] -- A non-strict parser may ignore a scheme in the reference */ | 174 | | /* [00/32] -- if it is identical to the base URI's scheme. */ | 175 | | /* [00/32] if ((not strict) and (R.scheme == Base.scheme)) then */ | 176 | 354 | relSourceHasScheme = (relSource->scheme.first != NULL) ? URI_TRUE : URI_FALSE; | 177 | 354 | if ((options & URI_RESOLVE_IDENTICAL_SCHEME_COMPAT) | 178 | 354 | && (absBase->scheme.first != NULL) | 179 | 354 | && (relSource->scheme.first != NULL) | 180 | 354 | && (0 == URI_FUNC(CompareRange)(&(absBase->scheme), &(relSource->scheme)))) { | 181 | | /* [00/32] undefine(R.scheme); */ | 182 | 0 | relSourceHasScheme = URI_FALSE; | 183 | | /* [00/32] endif; */ | 184 | 0 | } | 185 | | | 186 | | /* [01/32] if defined(R.scheme) then */ | 187 | 354 | if (relSourceHasScheme) { | 188 | | /* [02/32] T.scheme = R.scheme; */ | 189 | 201 | absDest->scheme = relSource->scheme; | 190 | | /* [03/32] T.authority = R.authority; */ | 191 | 201 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { | 192 | 0 | return URI_ERROR_MALLOC; | 193 | 0 | } | 194 | | /* [04/32] T.path = remove_dot_segments(R.path); */ | 195 | 201 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { | 196 | 0 | return URI_ERROR_MALLOC; | 197 | 0 | } | 198 | 201 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { | 199 | 0 | return URI_ERROR_MALLOC; | 200 | 0 | } | 201 | | /* [05/32] T.query = R.query; */ | 202 | 201 | absDest->query = relSource->query; | 203 | | /* [06/32] else */ | 204 | 201 | } else { | 205 | | /* [07/32] if defined(R.authority) then */ | 206 | 153 | if (URI_FUNC(HasHost)(relSource)) { | 207 | | /* [08/32] T.authority = R.authority; */ | 208 | 3 | if (!URI_FUNC(CopyAuthority)(absDest, relSource, memory)) { | 209 | 0 | return URI_ERROR_MALLOC; | 210 | 0 | } | 211 | | /* [09/32] T.path = remove_dot_segments(R.path); */ | 212 | 3 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { | 213 | 0 | return URI_ERROR_MALLOC; | 214 | 0 | } | 215 | 3 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { | 216 | 0 | return URI_ERROR_MALLOC; | 217 | 0 | } | 218 | | /* [10/32] T.query = R.query; */ | 219 | 3 | absDest->query = relSource->query; | 220 | | /* [11/32] else */ | 221 | 150 | } else { | 222 | | /* [28/32] T.authority = Base.authority; */ | 223 | 150 | if (!URI_FUNC(CopyAuthority)(absDest, absBase, memory)) { | 224 | 0 | return URI_ERROR_MALLOC; | 225 | 0 | } | 226 | | /* [12/32] if (R.path == "") then */ | 227 | 150 | if (relSource->pathHead == NULL && !relSource->absolutePath) { | 228 | | /* [13/32] T.path = Base.path; */ | 229 | 72 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { | 230 | 0 | return URI_ERROR_MALLOC; | 231 | 0 | } | 232 | | /* [14/32] if defined(R.query) then */ | 233 | 72 | if (relSource->query.first != NULL) { | 234 | | /* [15/32] T.query = R.query; */ | 235 | 1 | absDest->query = relSource->query; | 236 | | /* [16/32] else */ | 237 | 71 | } else { | 238 | | /* [17/32] T.query = Base.query; */ | 239 | 71 | absDest->query = absBase->query; | 240 | | /* [18/32] endif; */ | 241 | 71 | } | 242 | | /* [19/32] else */ | 243 | 78 | } else { | 244 | | /* [20/32] if (R.path starts-with "/") then */ | 245 | 78 | if (relSource->absolutePath) { | 246 | 6 | int res; | 247 | | /* [21/32] T.path = remove_dot_segments(R.path); */ | 248 | 6 | if (!URI_FUNC(CopyPath)(absDest, relSource, memory)) { | 249 | 0 | return URI_ERROR_MALLOC; | 250 | 0 | } | 251 | 6 | res = URI_FUNC(ResolveAbsolutePathFlag)(absDest, memory); | 252 | 6 | if (res != URI_SUCCESS) { | 253 | 0 | return res; | 254 | 0 | } | 255 | 6 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { | 256 | 0 | return URI_ERROR_MALLOC; | 257 | 0 | } | 258 | | /* [22/32] else */ | 259 | 72 | } else { | 260 | | /* [23/32] T.path = merge(Base.path, R.path); */ | 261 | 72 | if (!URI_FUNC(CopyPath)(absDest, absBase, memory)) { | 262 | 0 | return URI_ERROR_MALLOC; | 263 | 0 | } | 264 | 72 | if (!URI_FUNC(MergePath)(absDest, relSource, memory)) { | 265 | 0 | return URI_ERROR_MALLOC; | 266 | 0 | } | 267 | | /* [24/32] T.path = remove_dot_segments(T.path); */ | 268 | 72 | if (!URI_FUNC(RemoveDotSegmentsAbsolute)(absDest, memory)) { | 269 | 0 | return URI_ERROR_MALLOC; | 270 | 0 | } | 271 | | | 272 | 72 | if (!URI_FUNC(FixAmbiguity)(absDest, memory)) { | 273 | 0 | return URI_ERROR_MALLOC; | 274 | 0 | } | 275 | | /* [25/32] endif; */ | 276 | 72 | } | 277 | | /* [26/32] T.query = R.query; */ | 278 | 78 | absDest->query = relSource->query; | 279 | | /* [27/32] endif; */ | 280 | 78 | } | 281 | 150 | URI_FUNC(FixEmptyTrailSegment)(absDest, memory); | 282 | | /* [29/32] endif; */ | 283 | 150 | } | 284 | | /* [30/32] T.scheme = Base.scheme; */ | 285 | 153 | absDest->scheme = absBase->scheme; | 286 | | /* [31/32] endif; */ | 287 | 153 | } | 288 | | /* [32/32] T.fragment = R.fragment; */ | 289 | 354 | absDest->fragment = relSource->fragment; | 290 | | | 291 | 354 | return URI_SUCCESS; | 292 | | | 293 | 354 | } |
Unexecuted instantiation: UriResolve.c:uriAddBaseUriImplW |
294 | | |
295 | | |
296 | | |
297 | | int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absDest, |
298 | 7.04k | const URI_TYPE(Uri) * relSource, const URI_TYPE(Uri) * absBase) { |
299 | 7.04k | const UriResolutionOptions options = URI_RESOLVE_STRICTLY; |
300 | 7.04k | return URI_FUNC(AddBaseUriEx)(absDest, relSource, absBase, options); |
301 | 7.04k | } Line | Count | Source | 298 | 7.04k | const URI_TYPE(Uri) * relSource, const URI_TYPE(Uri) * absBase) { | 299 | 7.04k | const UriResolutionOptions options = URI_RESOLVE_STRICTLY; | 300 | 7.04k | return URI_FUNC(AddBaseUriEx)(absDest, relSource, absBase, options); | 301 | 7.04k | } |
Unexecuted instantiation: uriAddBaseUriW |
302 | | |
303 | | |
304 | | |
305 | | int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absDest, |
306 | | const URI_TYPE(Uri) * relSource, const URI_TYPE(Uri) * absBase, |
307 | 7.04k | UriResolutionOptions options) { |
308 | 7.04k | return URI_FUNC(AddBaseUriExMm)(absDest, relSource, absBase, options, NULL); |
309 | 7.04k | } Line | Count | Source | 307 | 7.04k | UriResolutionOptions options) { | 308 | 7.04k | return URI_FUNC(AddBaseUriExMm)(absDest, relSource, absBase, options, NULL); | 309 | 7.04k | } |
Unexecuted instantiation: uriAddBaseUriExW |
310 | | |
311 | | |
312 | | |
313 | | int URI_FUNC(AddBaseUriExMm)(URI_TYPE(Uri) * absDest, |
314 | | const URI_TYPE(Uri) * relSource, const URI_TYPE(Uri) * absBase, |
315 | 7.04k | UriResolutionOptions options, UriMemoryManager * memory) { |
316 | 7.04k | int res; |
317 | | |
318 | 7.04k | URI_CHECK_MEMORY_MANAGER(memory); /* may return */ |
319 | | |
320 | 7.04k | res = URI_FUNC(AddBaseUriImpl)(absDest, relSource, absBase, options, memory); |
321 | 7.04k | if ((res != URI_SUCCESS) && (absDest != NULL)) { |
322 | 6.69k | URI_FUNC(FreeUriMembersMm)(absDest, memory); |
323 | 6.69k | } |
324 | 7.04k | return res; |
325 | 7.04k | } Line | Count | Source | 315 | 7.04k | UriResolutionOptions options, UriMemoryManager * memory) { | 316 | 7.04k | int res; | 317 | | | 318 | 7.04k | URI_CHECK_MEMORY_MANAGER(memory); /* may return */ | 319 | | | 320 | 7.04k | res = URI_FUNC(AddBaseUriImpl)(absDest, relSource, absBase, options, memory); | 321 | 7.04k | if ((res != URI_SUCCESS) && (absDest != NULL)) { | 322 | 6.69k | URI_FUNC(FreeUriMembersMm)(absDest, memory); | 323 | 6.69k | } | 324 | 7.04k | return res; | 325 | 7.04k | } |
Unexecuted instantiation: uriAddBaseUriExMmW |
326 | | |
327 | | |
328 | | |
329 | | #endif |