mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
update
This commit is contained in:
parent
9743860d35
commit
d41773e8b6
@ -1,5 +1,5 @@
|
||||
/* Generated by re2c 0.5 on Fri May 3 10:31:33 2002 */
|
||||
#line 1 "/home/thies/devel/php4/ext/standard/url_scanner_ex.re"
|
||||
/* Generated by re2c 0.5 on Sat May 4 20:29:07 2002 */
|
||||
#line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re"
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
@ -86,7 +86,7 @@ PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("url_rewriter.tags", "a=href,area=href,frame=src,form=fakeentry", PHP_INI_ALL, OnUpdateTags, url_adapt_state_ex, php_basic_globals, basic_globals)
|
||||
PHP_INI_END()
|
||||
|
||||
#line 90
|
||||
#line 91
|
||||
|
||||
|
||||
#define YYFILL(n) goto done
|
||||
@ -95,15 +95,11 @@ PHP_INI_END()
|
||||
#define YYLIMIT q
|
||||
#define YYMARKER r
|
||||
|
||||
static inline void append_modified_url(smart_str *url, smart_str *dest, HashTable *rewrite_vars, const char *separator)
|
||||
static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator)
|
||||
{
|
||||
register const char *p, *q;
|
||||
const char *bash = NULL;
|
||||
const char *sep = "?";
|
||||
char *string_key;
|
||||
url_adapt_var_t *value;
|
||||
int num_key;
|
||||
|
||||
|
||||
q = (p = url->c) + url->len;
|
||||
|
||||
@ -155,25 +151,25 @@ yy0:
|
||||
if(yych >= ';') goto yy4;
|
||||
yy2: yych = *++YYCURSOR;
|
||||
yy3:
|
||||
#line 112
|
||||
#line 109
|
||||
{ smart_str_append(dest, url); return; }
|
||||
yy4: yych = *++YYCURSOR;
|
||||
yy5:
|
||||
#line 113
|
||||
#line 110
|
||||
{ sep = separator; goto scan; }
|
||||
yy6: yych = *++YYCURSOR;
|
||||
yy7:
|
||||
#line 114
|
||||
#line 111
|
||||
{ bash = p - 1; goto done; }
|
||||
yy8: ++YYCURSOR;
|
||||
if(YYLIMIT == YYCURSOR) YYFILL(1);
|
||||
yych = *YYCURSOR;
|
||||
yy9: if(yybm[0+yych] & 128) goto yy8;
|
||||
yy10:
|
||||
#line 115
|
||||
#line 112
|
||||
{ goto scan; }
|
||||
}
|
||||
#line 116
|
||||
#line 113
|
||||
|
||||
done:
|
||||
|
||||
@ -188,16 +184,8 @@ done:
|
||||
else
|
||||
smart_str_append(dest, url);
|
||||
|
||||
zend_hash_internal_pointer_reset(rewrite_vars);
|
||||
while (zend_hash_get_current_key(rewrite_vars, &string_key, &num_key, 0) != HASH_KEY_NON_EXISTANT) {
|
||||
zend_hash_get_current_data(rewrite_vars, &value);
|
||||
smart_str_appends(dest, sep);
|
||||
smart_str_append(dest, &(value->var));
|
||||
smart_str_appendc(dest, '=');
|
||||
smart_str_append(dest, &(value->val));
|
||||
zend_hash_move_forward(rewrite_vars);
|
||||
sep = separator; /* switch from ? to now! */
|
||||
}
|
||||
smart_str_appends(dest, sep);
|
||||
smart_str_append(dest, url_app);
|
||||
|
||||
if (bash)
|
||||
smart_str_appendl(dest, bash, q - bash);
|
||||
@ -220,7 +208,7 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type TSR
|
||||
if (quotes)
|
||||
smart_str_appendc(&ctx->result, type);
|
||||
if (f) {
|
||||
append_modified_url(&ctx->val, &ctx->result, ctx->rewrite_vars, PG(arg_separator).output);
|
||||
append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output);
|
||||
} else {
|
||||
smart_str_append(&ctx->result, &ctx->val);
|
||||
}
|
||||
@ -254,21 +242,10 @@ static inline void passthru(STD_PARA)
|
||||
|
||||
static inline void handle_form(STD_PARA)
|
||||
{
|
||||
if (ctx->tag.len == 4 && strncasecmp(ctx->tag.c, "form", 4) == 0) {
|
||||
char *string_key;
|
||||
url_adapt_var_t *value;
|
||||
int num_key;
|
||||
|
||||
zend_hash_internal_pointer_reset(ctx->rewrite_vars);
|
||||
while (zend_hash_get_current_key(ctx->rewrite_vars, &string_key, &num_key, 0) != HASH_KEY_NON_EXISTANT) {
|
||||
zend_hash_get_current_data(ctx->rewrite_vars, &value);
|
||||
smart_str_appends(&ctx->result, "<input type=\"hidden\" name=\"");
|
||||
smart_str_append(&ctx->result, &(value->var));
|
||||
smart_str_appends(&ctx->result, "\" value=\"");
|
||||
smart_str_append(&ctx->result, &(value->val));
|
||||
smart_str_appends(&ctx->result, "\" />");
|
||||
zend_hash_move_forward(ctx->rewrite_vars);
|
||||
}
|
||||
if (ctx->form_app.len > 0
|
||||
&& ctx->tag.len == 4
|
||||
&& strncasecmp(ctx->tag.c, "form", 4) == 0) {
|
||||
smart_str_append(&ctx->result, &ctx->form_app);
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,17 +360,17 @@ yy11:
|
||||
if(yybm[0+yych] & 128) goto yy15;
|
||||
yy13: yych = *++YYCURSOR;
|
||||
yy14:
|
||||
#line 281
|
||||
#line 259
|
||||
{ passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
|
||||
yy15: ++YYCURSOR;
|
||||
if(YYLIMIT == YYCURSOR) YYFILL(1);
|
||||
yych = *YYCURSOR;
|
||||
yy16: if(yybm[0+yych] & 128) goto yy15;
|
||||
yy17:
|
||||
#line 282
|
||||
#line 260
|
||||
{ passthru(STD_ARGS); goto state_plain; }
|
||||
}
|
||||
#line 283
|
||||
#line 261
|
||||
|
||||
|
||||
state_tag:
|
||||
@ -447,11 +424,11 @@ yy18:
|
||||
yy20: yych = *++YYCURSOR;
|
||||
goto yy25;
|
||||
yy21:
|
||||
#line 288
|
||||
#line 266
|
||||
{ handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
|
||||
yy22: yych = *++YYCURSOR;
|
||||
yy23:
|
||||
#line 289
|
||||
#line 267
|
||||
{ passthru(STD_ARGS); goto state_plain_begin; }
|
||||
yy24: ++YYCURSOR;
|
||||
if(YYLIMIT == YYCURSOR) YYFILL(1);
|
||||
@ -459,7 +436,7 @@ yy24: ++YYCURSOR;
|
||||
yy25: if(yybm[0+yych] & 128) goto yy24;
|
||||
goto yy21;
|
||||
}
|
||||
#line 290
|
||||
#line 268
|
||||
|
||||
|
||||
state_next_arg_begin:
|
||||
@ -530,20 +507,20 @@ yy26:
|
||||
}
|
||||
yy28: yych = *++YYCURSOR;
|
||||
yy29:
|
||||
#line 298
|
||||
#line 276
|
||||
{ passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
|
||||
yy30: yych = *++YYCURSOR;
|
||||
goto yy37;
|
||||
yy31:
|
||||
#line 299
|
||||
#line 277
|
||||
{ passthru(STD_ARGS); goto state_next_arg; }
|
||||
yy32: yych = *++YYCURSOR;
|
||||
yy33:
|
||||
#line 300
|
||||
#line 278
|
||||
{ --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
|
||||
yy34: yych = *++YYCURSOR;
|
||||
yy35:
|
||||
#line 301
|
||||
#line 279
|
||||
{ passthru(STD_ARGS); goto state_plain_begin; }
|
||||
yy36: ++YYCURSOR;
|
||||
if(YYLIMIT == YYCURSOR) YYFILL(1);
|
||||
@ -551,7 +528,7 @@ yy36: ++YYCURSOR;
|
||||
yy37: if(yybm[0+yych] & 128) goto yy36;
|
||||
goto yy31;
|
||||
}
|
||||
#line 302
|
||||
#line 280
|
||||
|
||||
|
||||
state_arg:
|
||||
@ -605,11 +582,11 @@ yy38:
|
||||
yy40: yych = *++YYCURSOR;
|
||||
goto yy45;
|
||||
yy41:
|
||||
#line 307
|
||||
#line 285
|
||||
{ passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
|
||||
yy42: yych = *++YYCURSOR;
|
||||
yy43:
|
||||
#line 308
|
||||
#line 286
|
||||
{ passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; }
|
||||
yy44: ++YYCURSOR;
|
||||
if(YYLIMIT == YYCURSOR) YYFILL(1);
|
||||
@ -617,7 +594,7 @@ yy44: ++YYCURSOR;
|
||||
yy45: if(yybm[0+yych] & 128) goto yy44;
|
||||
goto yy41;
|
||||
}
|
||||
#line 309
|
||||
#line 287
|
||||
|
||||
|
||||
state_before_val:
|
||||
@ -672,12 +649,12 @@ yy48: yyaccept = 0;
|
||||
if(yych == ' ') goto yy55;
|
||||
if(yych == '=') goto yy53;
|
||||
yy49:
|
||||
#line 315
|
||||
#line 293
|
||||
{ --YYCURSOR; goto state_next_arg_begin; }
|
||||
yy50: yych = *++YYCURSOR;
|
||||
goto yy54;
|
||||
yy51:
|
||||
#line 314
|
||||
#line 292
|
||||
{ passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
|
||||
yy52: yych = *++YYCURSOR;
|
||||
goto yy49;
|
||||
@ -696,7 +673,7 @@ yy57: YYCURSOR = YYMARKER;
|
||||
case 0: goto yy49;
|
||||
}
|
||||
}
|
||||
#line 316
|
||||
#line 294
|
||||
|
||||
|
||||
|
||||
@ -766,7 +743,7 @@ yy60: yyaccept = 0;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if(yych != '>') goto yy74;
|
||||
yy61:
|
||||
#line 325
|
||||
#line 303
|
||||
{ passthru(STD_ARGS); goto state_next_arg_begin; }
|
||||
yy62: yyaccept = 0;
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
@ -775,7 +752,7 @@ yy62: yyaccept = 0;
|
||||
yy63: yych = *++YYCURSOR;
|
||||
goto yy67;
|
||||
yy64:
|
||||
#line 324
|
||||
#line 302
|
||||
{ handle_val(STD_ARGS, 0, '"'); goto state_next_arg_begin; }
|
||||
yy65: yych = *++YYCURSOR;
|
||||
goto yy61;
|
||||
@ -795,7 +772,7 @@ yy70: YYCURSOR = YYMARKER;
|
||||
}
|
||||
yy71: yych = *++YYCURSOR;
|
||||
yy72:
|
||||
#line 323
|
||||
#line 301
|
||||
{ handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
|
||||
yy73: ++YYCURSOR;
|
||||
if(YYLIMIT == YYCURSOR) YYFILL(1);
|
||||
@ -804,10 +781,10 @@ yy74: if(yybm[0+yych] & 128) goto yy73;
|
||||
if(yych >= '>') goto yy70;
|
||||
yy75: yych = *++YYCURSOR;
|
||||
yy76:
|
||||
#line 322
|
||||
#line 300
|
||||
{ handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
|
||||
}
|
||||
#line 326
|
||||
#line 304
|
||||
|
||||
|
||||
stop:
|
||||
@ -873,56 +850,60 @@ int php_url_scanner_ex_deactivate(TSRMLS_D)
|
||||
|
||||
static void php_url_scanner_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
|
||||
{
|
||||
if (BG(url_adapt_state_ex).rewrite_vars && zend_hash_num_elements(BG(url_adapt_state_ex).rewrite_vars)) {
|
||||
if (BG(url_adapt_state_ex).url_app.len != 0) {
|
||||
*handled_output = url_adapt_ext(output, output_len, handled_output_len, (zend_bool) (mode&PHP_OUTPUT_HANDLER_END ? 1 : 0) TSRMLS_CC);
|
||||
} else {
|
||||
*handled_output = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void php_url_scanner_var_dtor(url_adapt_var_t *var)
|
||||
{
|
||||
smart_str_free(&(var->var));
|
||||
smart_str_free(&(var->val));
|
||||
}
|
||||
|
||||
int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC)
|
||||
{
|
||||
url_adapt_var_t var;
|
||||
char *encoded;
|
||||
int encoded_len;
|
||||
|
||||
smart_str val;
|
||||
|
||||
if (! BG(url_adapt_state_ex).active) {
|
||||
int chunk_size = 4096; /* XXX where should we get chunk_size from? */
|
||||
|
||||
php_url_scanner_ex_activate(TSRMLS_C);
|
||||
php_start_ob_buffer(NULL, chunk_size, 1 TSRMLS_CC);
|
||||
php_ob_set_internal_handler(php_url_scanner_output_handler, chunk_size, "URL-Rewriter", 1 TSRMLS_CC);
|
||||
php_ob_set_internal_handler(php_url_scanner_output_handler, chunk_size, estrdup("URL-Rewriter"), 1 TSRMLS_CC);
|
||||
BG(url_adapt_state_ex).active = 1;
|
||||
}
|
||||
|
||||
if (! BG(url_adapt_state_ex).rewrite_vars) {
|
||||
BG(url_adapt_state_ex).rewrite_vars = emalloc(sizeof(HashTable));
|
||||
zend_hash_init(BG(url_adapt_state_ex).rewrite_vars, 0, NULL, (void (*)(void *)) php_url_scanner_var_dtor, 0);
|
||||
}
|
||||
|
||||
smart_str_setl(&(var.var), estrndup(name, name_len), name_len);
|
||||
if (BG(url_adapt_state_ex).url_app.len != 0) {
|
||||
smart_str_appends(&BG(url_adapt_state_ex).url_app, PG(arg_separator).output);
|
||||
}
|
||||
|
||||
if (urlencode) {
|
||||
encoded = php_url_encode(value, value_len, &encoded_len);
|
||||
smart_str_setl(&(var.val), encoded, encoded_len);
|
||||
smart_str_setl(&val, encoded, encoded_len);
|
||||
} else {
|
||||
smart_str_setl(&(var.val), estrndup(value, value_len), value_len);
|
||||
smart_str_setl(&val, value, value_len);
|
||||
}
|
||||
|
||||
smart_str_appendl(&BG(url_adapt_state_ex).url_app, name, name_len);
|
||||
smart_str_appendc(&BG(url_adapt_state_ex).url_app, '=');
|
||||
smart_str_append(&BG(url_adapt_state_ex).url_app, &val);
|
||||
|
||||
return zend_hash_add(BG(url_adapt_state_ex).rewrite_vars, name, name_len, &var, sizeof(url_adapt_var_t), NULL);
|
||||
smart_str_appends(&BG(url_adapt_state_ex).form_app, "<input type=\"hidden\" name=\"");
|
||||
smart_str_appendl(&BG(url_adapt_state_ex).form_app, name, name_len);
|
||||
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" value=\"");
|
||||
smart_str_append(&BG(url_adapt_state_ex).form_app, &val);
|
||||
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" />");
|
||||
|
||||
if (urlencode)
|
||||
efree(encoded);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int php_url_scanner_remove_var(char *name, int name_len TSRMLS_DC)
|
||||
int php_url_scanner_reset_vars(TSRMLS_D)
|
||||
{
|
||||
if (BG(url_adapt_state_ex).rewrite_vars) {
|
||||
return zend_hash_del(BG(url_adapt_state_ex).rewrite_vars, name, name_len);
|
||||
}
|
||||
BG(url_adapt_state_ex).form_app.len = 0;
|
||||
BG(url_adapt_state_ex).url_app.len = 0;
|
||||
|
||||
return FAILURE;
|
||||
}
|
||||
@ -931,6 +912,9 @@ PHP_MINIT_FUNCTION(url_scanner)
|
||||
{
|
||||
BG(url_adapt_state_ex).tags = NULL;
|
||||
|
||||
BG(url_adapt_state_ex).form_app.c = BG(url_adapt_state_ex).url_app.c = 0;
|
||||
BG(url_adapt_state_ex).form_app.len = BG(url_adapt_state_ex).url_app.len = 0;
|
||||
|
||||
REGISTER_INI_ENTRIES();
|
||||
return SUCCESS;
|
||||
}
|
||||
@ -947,8 +931,10 @@ PHP_MSHUTDOWN_FUNCTION(url_scanner)
|
||||
PHP_RINIT_FUNCTION(url_scanner)
|
||||
{
|
||||
BG(url_adapt_state_ex).active = 0;
|
||||
BG(url_adapt_state_ex).rewrite_vars = NULL;
|
||||
|
||||
smart_str_free(&BG(url_adapt_state_ex).form_app);
|
||||
smart_str_free(&BG(url_adapt_state_ex).url_app);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -959,11 +945,5 @@ PHP_RSHUTDOWN_FUNCTION(url_scanner)
|
||||
BG(url_adapt_state_ex).active = 0;
|
||||
}
|
||||
|
||||
if (BG(url_adapt_state_ex).rewrite_vars) {
|
||||
zend_hash_destroy(BG(url_adapt_state_ex).rewrite_vars);
|
||||
efree(BG(url_adapt_state_ex).rewrite_vars);
|
||||
BG(url_adapt_state_ex).rewrite_vars = NULL;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user