diff options
Diffstat (limited to 'src/gmutil.c')
-rw-r--r-- | src/gmutil.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gmutil.c b/src/gmutil.c index 68525be9..afca4978 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -151,6 +151,42 @@ static iString *punyDecodeHost_(iRangecc host) { | |||
151 | return result; | 151 | return result; |
152 | } | 152 | } |
153 | 153 | ||
154 | void urlDecodePath_String(iString *d) { | ||
155 | iUrl url; | ||
156 | init_Url(&url, d); | ||
157 | if (isEmpty_Range(&url.path)) { | ||
158 | return; | ||
159 | } | ||
160 | iString *decoded = new_String(); | ||
161 | appendRange_String(decoded, (iRangecc){ constBegin_String(d), url.path.start }); | ||
162 | iString *path = newRange_String(url.path); | ||
163 | iString *decPath = urlDecode_String(path); | ||
164 | append_String(decoded, decPath); | ||
165 | delete_String(decPath); | ||
166 | delete_String(path); | ||
167 | appendRange_String(decoded, (iRangecc){ url.path.end, constEnd_String(d) }); | ||
168 | set_String(d, decoded); | ||
169 | delete_String(decoded); | ||
170 | } | ||
171 | |||
172 | void urlEncodePath_String(iString *d) { | ||
173 | iUrl url; | ||
174 | init_Url(&url, d); | ||
175 | if (isEmpty_Range(&url.path)) { | ||
176 | return; | ||
177 | } | ||
178 | iString *encoded = new_String(); | ||
179 | appendRange_String(encoded , (iRangecc){ constBegin_String(d), url.path.start }); | ||
180 | iString *path = newRange_String(url.path); | ||
181 | iString *encPath = urlEncodeExclude_String(path, "%/ "); | ||
182 | append_String(encoded, encPath); | ||
183 | delete_String(encPath); | ||
184 | delete_String(path); | ||
185 | appendRange_String(encoded, (iRangecc){ url.path.end, constEnd_String(d) }); | ||
186 | set_String(d, encoded); | ||
187 | delete_String(encoded); | ||
188 | } | ||
189 | |||
154 | const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelative) { | 190 | const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelative) { |
155 | iUrl orig; | 191 | iUrl orig; |
156 | iUrl rel; | 192 | iUrl rel; |