Skip to content

Commit c34d2b9

Browse files
author
foobar
committed
Added new configuration directives:
arg_separator.input and arg_separator.output
1 parent 382e3c5 commit c34d2b9

10 files changed

+61
-19
lines changed

NEWS

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ PHP 4.0 NEWS
3030
(Zeev)
3131

3232
?? ??? 200?, Version 4.0.5
33-
- New FastCGI server module. (Ben Mansell)
33+
- Added new php.ini directive: arg_separator.input which is used to tell
34+
PHP which characters are considered as argument separators in URLs.
35+
Renamed php.ini directive: arg_separator -> arg_separator.output (Jani)
36+
- Added FastCGI SAPI module. (Ben Mansell)
3437
- Added array_reduce(), which allows iterative reduction of an array
3538
to a single value via a callback function. (Andrei)
3639
- The imageloadfont function of the gd extension should be not platform

ext/standard/url_scanner.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ static char *url_attr_addon(const char *tag,const char *attr,const char *val,con
6767
if(flag) {
6868
if(!strstr(val,buf)&&!strchr(val,':'))
6969
{
70-
char *result = (char *)emalloc(strlen(buf)+strlen(PG(arg_separator))+1);
70+
char *result = (char *)emalloc(strlen(buf)+strlen(PG(arg_separator).output)+1);
7171
int n;
7272

7373
if(strchr(val,'?')) {
74-
strcpy(result,PG(arg_separator));
75-
n=strlen(PG(arg_separator));
74+
strcpy(result,PG(arg_separator).output);
75+
n=strlen(PG(arg_separator).output);
7676
} else {
7777
*result='?';
7878
n=1;

ext/standard/url_scanner_ex.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Generated by re2c 0.5 on Tue Jan 9 17:13:20 2001 */
2-
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
1+
/* Generated by re2c 0.5 on Wed Apr 4 19:29:46 2001 */
2+
#line 1 "/usr/src/web/php/php4/ext/standard/url_scanner_ex.re"
33
/*
44
+----------------------------------------------------------------------+
55
| PHP version 4.0 |
@@ -140,7 +140,7 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx, char quote PLS_DC)
140140

141141
smart_str_appendc(&ctx->result, quote);
142142
if (f) {
143-
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator));
143+
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator).output);
144144
} else {
145145
smart_str_append(&ctx->result, &ctx->val);
146146
}
@@ -670,7 +670,7 @@ char *url_adapt_single_url(const char *url, size_t urllen, const char *name, con
670670
smart_str_sets(&sname, name);
671671
smart_str_sets(&sval, value);
672672

673-
append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator));
673+
append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator).output);
674674

675675
smart_str_0(&buf);
676676
if (newlen) *newlen = buf.len;

ext/standard/url_scanner_ex.re

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx, char quote PLS_DC)
138138

139139
smart_str_appendc(&ctx->result, quote);
140140
if (f) {
141-
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator));
141+
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator).output);
142142
} else {
143143
smart_str_append(&ctx->result, &ctx->val);
144144
}
@@ -313,7 +313,7 @@ char *url_adapt_single_url(const char *url, size_t urllen, const char *name, con
313313
smart_str_sets(&sname, name);
314314
smart_str_sets(&sval, value);
315315

316-
append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator));
316+
append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator).output);
317317

318318
smart_str_0(&buf);
319319
if (newlen) *newlen = buf.len;

main/main.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ PHP_INI_BEGIN()
209209
STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
210210
STD_PHP_INI_BOOLEAN("y2k_compliance", "0", PHP_INI_ALL, OnUpdateBool, y2k_compliance, php_core_globals, core_globals)
211211

212-
STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals)
212+
STD_PHP_INI_ENTRY("arg_separator.output", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator.output, php_core_globals, core_globals)
213+
STD_PHP_INI_ENTRY("arg_separator.input", "&", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateStringUnempty, arg_separator.input, php_core_globals, core_globals)
214+
213215
STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals)
214216
STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals)
215217
STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals)

main/php_globals.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ extern ZEND_API struct _php_core_globals core_globals;
5252

5353
struct _php_tick_function_entry;
5454

55+
typedef struct _arg_separators {
56+
char *output;
57+
char *input;
58+
} arg_separators;
59+
5560
struct _php_core_globals {
5661
zend_bool magic_quotes_gpc;
5762
zend_bool magic_quotes_runtime;
@@ -93,7 +98,8 @@ struct _php_core_globals {
9398
char *auto_prepend_file;
9499
char *auto_append_file;
95100

96-
char *arg_separator;
101+
arg_separators arg_separator;
102+
97103
char *gpc_order;
98104
char *variables_order;
99105

main/php_variables.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ SAPI_POST_HANDLER_FUNC(php_std_post_handler)
217217

218218
void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
219219
{
220-
char *res = NULL, *var, *val, *separator = ";&";
220+
char *res = NULL, *var, *val, *separator=NULL;
221221
const char *c_var;
222222
pval *array_ptr;
223223
int free_buffer=0;
@@ -238,7 +238,6 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
238238
PG(http_globals)[TRACK_VARS_GET] = array_ptr;
239239
break;
240240
case PARSE_COOKIE:
241-
separator=";";
242241
PG(http_globals)[TRACK_VARS_COOKIE] = array_ptr;
243242
break;
244243
}
@@ -278,6 +277,16 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
278277
return;
279278
}
280279

280+
switch (arg) {
281+
case PARSE_GET:
282+
case PARSE_STRING:
283+
separator = (char *) estrdup(PG(arg_separator).input);
284+
break;
285+
case PARSE_COOKIE:
286+
separator = ";\0";
287+
break;
288+
}
289+
281290
var = php_strtok_r(res, separator, &strtok_buf);
282291

283292
while (var) {
@@ -292,6 +301,11 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
292301
}
293302
var = php_strtok_r(NULL, separator, &strtok_buf);
294303
}
304+
305+
if(arg != PARSE_COOKIE) {
306+
efree(separator);
307+
}
308+
295309
if (free_buffer) {
296310
efree(res);
297311
}

php.ini-dist

+6-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,12 @@ warn_plus_overloading = Off
243243

244244
; The separator used in PHP generated URLs to separate arguments.
245245
; Default is "&".
246-
;arg_separator = "&"
246+
;arg_separator.output = "&"
247+
248+
; List of separator(s) used by PHP to parse input URLs into variables.
249+
; Default is "&".
250+
; NOTE: Every character in this directive is considered as separator!
251+
;arg_separator.input = ";&"
247252

248253
; This directive describes the order in which PHP registers GET, POST, Cookie,
249254
; Environment and Built-in variables (G, P, C, E & S respectively, often

php.ini-optimized

+8-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,14 @@ warn_plus_overloading = Off ; warn if the + operator is used with strings
182182
;;;;;;;;;;;;;;;;;
183183
; Data Handling ;
184184
;;;;;;;;;;;;;;;;;
185-
;arg_separator = "&" ; The separator used in PHP generated URLs to separate arguments.
186-
; Default is "&".
185+
186+
;arg_separator.output = "&" ; The separator used in PHP generated URLs to separate arguments.
187+
; Default is "&".
188+
189+
;arg_separator.input = ";&" ; List of separator(s) used by PHP to parse input URLs into variables.
190+
; Default is "&".
191+
; NOTE: Every character in this directive is considered as separator!
192+
187193
variables_order = "GPCS" ; This directive describes the order in which PHP registers
188194
; GET, POST, Cookie, Environment and Built-in variables (G, P,
189195
; C, E & S respectively, often referred to as EGPCS or GPC).

php.ini-recommended

+8-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,14 @@ warn_plus_overloading = Off ; warn if the + operator is used with strings
182182
;;;;;;;;;;;;;;;;;
183183
; Data Handling ;
184184
;;;;;;;;;;;;;;;;;
185-
;arg_separator = "&" ; The separator used in PHP generated URLs to separate arguments.
186-
; Default is "&".
185+
186+
;arg_separator.output = "&" ; The separator used in PHP generated URLs to separate arguments.
187+
; Default is "&".
188+
189+
;arg_separator.input = ";&" ; List of separator(s) used by PHP to parse input URLs into variables.
190+
; Default is "&".
191+
; NOTE: Every character in this directive is considered as separator!
192+
187193
variables_order = "GPCS" ; This directive describes the order in which PHP registers
188194
; GET, POST, Cookie, Environment and Built-in variables (G, P,
189195
; C, E & S respectively, often referred to as EGPCS or GPC).

0 commit comments

Comments
 (0)