Project

General

Profile

mod_redirect_expansion-1.4.8.patch

mod_redirect url-encode and %%/$$ patch -- will - Anonymous, 2006-01-06 08:44

View differences:

lighttpd-1.4.8/src/mod_redirect.c 2006-01-06 00:13:14.766313576 -0800
214 214
			
215 215
			start = 0; end = pattern_len;
216 216
			for (k = 0; k < pattern_len; k++) {
217
				if ((pattern[k] == '$' || pattern[k] == '%') &&
218
				    isdigit((unsigned char)pattern[k + 1])) {
219
					/* got one */
220
					
221
					size_t num = pattern[k + 1] - '0';
222
					
223
					end = k;
224
					
225
					buffer_append_string_len(p->location, pattern + start, end - start);
226
					
227
					if (pattern[k] == '$') {
228
						/* n is always > 0 */
229
						if (num < (size_t)n) {
230
							buffer_append_string(p->location, list[num]);
217
				if ((pattern[k] == '$' || pattern[k] == '%')) {
218
					/* Support normal backreferences, url-encoded backreferences, 
219
					 * and ignored values %%, etc
220
					 */
221
					if (isdigit((unsigned char)pattern[k + 1])) {
222
						/* got one */
223

  
224
						size_t num = pattern[k + 1] - '0';
225

  
226
						end = k;
227

  
228
						buffer_append_string_len(p->location, pattern + start, end - start);
229

  
230
						if (pattern[k] == '$') {
231
							/* n is always > 0 */
232
							if (num < (size_t)n) {
233
								buffer_append_string(p->location, list[num]);
234
							}
235
						} else {
236
							config_append_cond_match_buffer(con, p->conf.context, p->location, num);
231 237
						}
232
					} else {
233
						config_append_cond_match_buffer(con, p->conf.context, p->location, num);
234
					}
235
					
236
					k++;
237
					start = k + 1;
238

  
239
						k++;
240
						start = k + 1;
241
					} else if (pattern[k + 1] == '$' || pattern[k + 1] == '%') { 
242
						end = k;
243
						buffer_append_string_len(p->location, pattern + start, end - start);
244
						/* Drop one of the two */
245
						k++;
246
						buffer_append_string_len(p->location, pattern + k, 2);
247

  
248
						k++;
249
						start = k + 1;
250
					} else if (pattern[k + 1] == '!' && isdigit((unsigned char)pattern[k + 2])) {
251
						/* got one */
252
						size_t num = 0;
253
						num = pattern[k + 2] - '0';
254

  
255
						end = k;
256

  
257
						buffer_append_string_len(p->location, pattern + start, end - start);
258

  
259
						if (pattern[k] == '$') {
260
							/* n is always > 0 */
261
							if (num < (size_t)n) {
262
								buffer_append_string_encoded(p->location, list[num],
263
									strlen(list[num]), ENCODING_REL_URI_PART);
264
							}
265
							k++;
266
						} else if (pattern[k] == '%') { /* Subst and escape */
267
							buffer *mbuf = buffer_init();
268
							config_append_cond_match_buffer(con, p->conf.context, mbuf, num);
269
							buffer_append_string_encoded(p->location, mbuf->ptr,
270
								mbuf->used - 1, ENCODING_REL_URI_PART);
271
							k++;
272
						}
273

  
274
						k++;
275
						start = k + 1;
276
					} 
238 277
				} 
239 278
			}
240 279