Skip to content

Commit

Permalink
Added new configuration directives:
Browse files Browse the repository at this point in the history
arg_separator.input and arg_separator.output
  • Loading branch information
foobar committed Apr 4, 2001
1 parent 382e3c5 commit c34d2b9
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 19 deletions.
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ PHP 4.0 NEWS
(Zeev)

?? ??? 200?, Version 4.0.5
- New FastCGI server module. (Ben Mansell)
- Added new php.ini directive: arg_separator.input which is used to tell
PHP which characters are considered as argument separators in URLs.
Renamed php.ini directive: arg_separator -> arg_separator.output (Jani)
- Added FastCGI SAPI module. (Ben Mansell)
- Added array_reduce(), which allows iterative reduction of an array
to a single value via a callback function. (Andrei)
- The imageloadfont function of the gd extension should be not platform
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/url_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ static char *url_attr_addon(const char *tag,const char *attr,const char *val,con
if(flag) {
if(!strstr(val,buf)&&!strchr(val,':'))
{
char *result = (char *)emalloc(strlen(buf)+strlen(PG(arg_separator))+1);
char *result = (char *)emalloc(strlen(buf)+strlen(PG(arg_separator).output)+1);
int n;

if(strchr(val,'?')) {
strcpy(result,PG(arg_separator));
n=strlen(PG(arg_separator));
strcpy(result,PG(arg_separator).output);
n=strlen(PG(arg_separator).output);
} else {
*result='?';
n=1;
Expand Down
8 changes: 4 additions & 4 deletions ext/standard/url_scanner_ex.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Generated by re2c 0.5 on Tue Jan 9 17:13:20 2001 */
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
/* Generated by re2c 0.5 on Wed Apr 4 19:29:46 2001 */
#line 1 "/usr/src/web/php/php4/ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
Expand Down Expand Up @@ -140,7 +140,7 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx, char quote PLS_DC)

smart_str_appendc(&ctx->result, quote);
if (f) {
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator));
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator).output);
} else {
smart_str_append(&ctx->result, &ctx->val);
}
Expand Down Expand Up @@ -670,7 +670,7 @@ char *url_adapt_single_url(const char *url, size_t urllen, const char *name, con
smart_str_sets(&sname, name);
smart_str_sets(&sval, value);

append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator));
append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator).output);

smart_str_0(&buf);
if (newlen) *newlen = buf.len;
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/url_scanner_ex.re
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx, char quote PLS_DC)

smart_str_appendc(&ctx->result, quote);
if (f) {
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator));
append_modified_url(&ctx->val, &ctx->result, &ctx->q_name, &ctx->q_value, PG(arg_separator).output);
} else {
smart_str_append(&ctx->result, &ctx->val);
}
Expand Down Expand Up @@ -313,7 +313,7 @@ char *url_adapt_single_url(const char *url, size_t urllen, const char *name, con
smart_str_sets(&sname, name);
smart_str_sets(&sval, value);

append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator));
append_modified_url(&surl, &buf, &sname, &sval, PG(arg_separator).output);

smart_str_0(&buf);
if (newlen) *newlen = buf.len;
Expand Down
4 changes: 3 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("y2k_compliance", "0", PHP_INI_ALL, OnUpdateBool, y2k_compliance, php_core_globals, core_globals)

STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("arg_separator.output", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator.output, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("arg_separator.input", "&", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateStringUnempty, arg_separator.input, php_core_globals, core_globals)

STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals)
Expand Down
8 changes: 7 additions & 1 deletion main/php_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ extern ZEND_API struct _php_core_globals core_globals;

struct _php_tick_function_entry;

typedef struct _arg_separators {
char *output;
char *input;
} arg_separators;

struct _php_core_globals {
zend_bool magic_quotes_gpc;
zend_bool magic_quotes_runtime;
Expand Down Expand Up @@ -93,7 +98,8 @@ struct _php_core_globals {
char *auto_prepend_file;
char *auto_append_file;

char *arg_separator;
arg_separators arg_separator;

char *gpc_order;
char *variables_order;

Expand Down
18 changes: 16 additions & 2 deletions main/php_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ SAPI_POST_HANDLER_FUNC(php_std_post_handler)

void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
{
char *res = NULL, *var, *val, *separator = ";&";
char *res = NULL, *var, *val, *separator=NULL;
const char *c_var;
pval *array_ptr;
int free_buffer=0;
Expand All @@ -238,7 +238,6 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
PG(http_globals)[TRACK_VARS_GET] = array_ptr;
break;
case PARSE_COOKIE:
separator=";";
PG(http_globals)[TRACK_VARS_COOKIE] = array_ptr;
break;
}
Expand Down Expand Up @@ -278,6 +277,16 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
return;
}

switch (arg) {
case PARSE_GET:
case PARSE_STRING:
separator = (char *) estrdup(PG(arg_separator).input);
break;
case PARSE_COOKIE:
separator = ";\0";
break;
}

var = php_strtok_r(res, separator, &strtok_buf);

while (var) {
Expand All @@ -292,6 +301,11 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
}
var = php_strtok_r(NULL, separator, &strtok_buf);
}

if(arg != PARSE_COOKIE) {
efree(separator);
}

if (free_buffer) {
efree(res);
}
Expand Down
7 changes: 6 additions & 1 deletion php.ini-dist
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ warn_plus_overloading = Off

; The separator used in PHP generated URLs to separate arguments.
; Default is "&".
;arg_separator = "&"
;arg_separator.output = "&"

; List of separator(s) used by PHP to parse input URLs into variables.
; Default is "&".
; NOTE: Every character in this directive is considered as separator!
;arg_separator.input = ";&"

; This directive describes the order in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
Expand Down
10 changes: 8 additions & 2 deletions php.ini-optimized
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,14 @@ warn_plus_overloading = Off ; warn if the + operator is used with strings
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
;arg_separator = "&" ; The separator used in PHP generated URLs to separate arguments.
; Default is "&".

;arg_separator.output = "&" ; The separator used in PHP generated URLs to separate arguments.
; Default is "&".

;arg_separator.input = ";&" ; List of separator(s) used by PHP to parse input URLs into variables.
; Default is "&".
; NOTE: Every character in this directive is considered as separator!

variables_order = "GPCS" ; This directive describes the order in which PHP registers
; GET, POST, Cookie, Environment and Built-in variables (G, P,
; C, E & S respectively, often referred to as EGPCS or GPC).
Expand Down
10 changes: 8 additions & 2 deletions php.ini-recommended
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,14 @@ warn_plus_overloading = Off ; warn if the + operator is used with strings
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
;arg_separator = "&" ; The separator used in PHP generated URLs to separate arguments.
; Default is "&".

;arg_separator.output = "&" ; The separator used in PHP generated URLs to separate arguments.
; Default is "&".

;arg_separator.input = ";&" ; List of separator(s) used by PHP to parse input URLs into variables.
; Default is "&".
; NOTE: Every character in this directive is considered as separator!

variables_order = "GPCS" ; This directive describes the order in which PHP registers
; GET, POST, Cookie, Environment and Built-in variables (G, P,
; C, E & S respectively, often referred to as EGPCS or GPC).
Expand Down

0 comments on commit c34d2b9

Please sign in to comment.