1
/* Generated by re2c 0.9.6 on Fri Apr 15 01:39:15 2005 */
2
#line 1 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
4
+----------------------------------------------------------------------+
6
+----------------------------------------------------------------------+
7
| Copyright (c) 1997-2004 The PHP Group |
8
+----------------------------------------------------------------------+
9
| This source file is subject to version 3.0 of the PHP license, |
10
| that is bundled with this package in the file LICENSE, and is |
11
| available through the world-wide-web at the following url: |
12
| http://www.php.net/license/3_0.txt. |
13
| If you did not receive a copy of the PHP license and are unable to |
14
| obtain it through the world-wide-web, please send a note to |
15
| license@php.net so we can mail you a copy immediately. |
16
+----------------------------------------------------------------------+
17
| Author: Sascha Schumann <sascha@schumann.cx> |
18
+----------------------------------------------------------------------+
35
#include "php_globals.h"
36
#define STATE_TAG SOME_OTHER_STATE_TAG
37
#include "basic_functions.h"
41
#define url_scanner url_scanner_ex
43
#include "php_smart_str.h"
45
static PHP_INI_MH(OnUpdateTags)
47
url_adapt_state_ex_t *ctx;
52
ctx = &BG(url_adapt_state_ex);
54
tmp = estrndup(new_value, new_value_length);
57
zend_hash_destroy(ctx->tags);
59
ctx->tags = malloc(sizeof(HashTable));
61
zend_hash_init(ctx->tags, 0, NULL, NULL, 1);
63
for (key = php_strtok_r(tmp, ",", &lasts);
65
key = php_strtok_r(NULL, ",", &lasts)) {
68
val = strchr(key, '=');
74
for (q = key; *q; q++)
77
/* key is stored withOUT NUL
78
val is stored WITH NUL */
79
zend_hash_add(ctx->tags, key, keylen, val, strlen(val)+1, NULL);
89
STD_PHP_INI_ENTRY("url_rewriter.tags", "a=href,area=href,frame=src,form=,fieldset=", PHP_INI_ALL, OnUpdateTags, url_adapt_state_ex, php_basic_globals, basic_globals)
92
#line 95 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
95
#define YYFILL(n) goto done
96
#define YYCTYPE unsigned char
101
static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator)
103
register const char *p, *q;
104
const char *bash = NULL;
105
const char *sep = "?";
107
q = (p = url->c) + url->len;
114
unsigned int yyaccept;
115
static unsigned char yybm[] = {
116
128, 128, 128, 128, 128, 128, 128, 128,
117
128, 128, 128, 128, 128, 128, 128, 128,
118
128, 128, 128, 128, 128, 128, 128, 128,
119
128, 128, 128, 128, 128, 128, 128, 128,
120
128, 128, 128, 0, 128, 128, 128, 128,
121
128, 128, 128, 128, 128, 128, 128, 128,
122
128, 128, 128, 128, 128, 128, 128, 128,
123
128, 128, 0, 128, 128, 128, 128, 0,
124
128, 128, 128, 128, 128, 128, 128, 128,
125
128, 128, 128, 128, 128, 128, 128, 128,
126
128, 128, 128, 128, 128, 128, 128, 128,
127
128, 128, 128, 128, 128, 128, 128, 128,
128
128, 128, 128, 128, 128, 128, 128, 128,
129
128, 128, 128, 128, 128, 128, 128, 128,
130
128, 128, 128, 128, 128, 128, 128, 128,
131
128, 128, 128, 128, 128, 128, 128, 128,
132
128, 128, 128, 128, 128, 128, 128, 128,
133
128, 128, 128, 128, 128, 128, 128, 128,
134
128, 128, 128, 128, 128, 128, 128, 128,
135
128, 128, 128, 128, 128, 128, 128, 128,
136
128, 128, 128, 128, 128, 128, 128, 128,
137
128, 128, 128, 128, 128, 128, 128, 128,
138
128, 128, 128, 128, 128, 128, 128, 128,
139
128, 128, 128, 128, 128, 128, 128, 128,
140
128, 128, 128, 128, 128, 128, 128, 128,
141
128, 128, 128, 128, 128, 128, 128, 128,
142
128, 128, 128, 128, 128, 128, 128, 128,
143
128, 128, 128, 128, 128, 128, 128, 128,
144
128, 128, 128, 128, 128, 128, 128, 128,
145
128, 128, 128, 128, 128, 128, 128, 128,
146
128, 128, 128, 128, 128, 128, 128, 128,
147
128, 128, 128, 128, 128, 128, 128, 128,
152
if(YYLIMIT == YYCURSOR) YYFILL(1);
154
if(yybm[0+yych] & 128) {
157
if(yych <= '9') goto yy6;
158
if(yych >= ';') goto yy4;
163
#line 113 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
164
{ smart_str_append(dest, url); return; }
169
#line 114 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
170
{ sep = separator; goto scan; }
175
#line 115 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
176
{ bash = p - 1; goto done; }
179
if(YYLIMIT == YYCURSOR) YYFILL(1);
182
yy9: if(yybm[0+yych] & 128) {
187
#line 116 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
191
#line 117 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
195
/* Don't modify URLs of the format "#mark" */
196
if (bash && bash - url->c == 0) {
197
smart_str_append(dest, url);
202
smart_str_appendl(dest, url->c, bash - url->c);
204
smart_str_append(dest, url);
206
smart_str_appends(dest, sep);
207
smart_str_append(dest, url_app);
210
smart_str_appendl(dest, bash, q - bash);
220
static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type TSRMLS_DC)
224
if (strncasecmp(ctx->arg.c, ctx->lookup_data, ctx->arg.len) == 0)
228
smart_str_appendc(&ctx->result, type);
230
append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output);
232
smart_str_append(&ctx->result, &ctx->val);
235
smart_str_appendc(&ctx->result, type);
247
#define YYFILL(n) goto stop
248
#define YYCTYPE unsigned char
252
#define STATE ctx->state
254
#define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR TSRMLS_DC
255
#define STD_ARGS ctx, start, xp TSRMLS_CC
258
#define scdebug(x) printf x
263
static inline void passthru(STD_PARA)
265
scdebug(("appending %d chars, starting with %c\n", YYCURSOR-start, *start));
266
smart_str_appendl(&ctx->result, start, YYCURSOR - start);
270
* This function appends a hidden input field after a <form> or
271
* <fieldset>. The latter is important for XHTML.
274
static void handle_form(STD_PARA)
278
if (ctx->form_app.len > 0) {
279
switch (ctx->tag.len) {
281
#define RECOGNIZE(x) do { \
283
if (strncasecmp(ctx->tag.c, x, sizeof(x)-1) == 0) \
289
RECOGNIZE("fieldset");
293
smart_str_append(&ctx->result, &ctx->form_app);
300
* HANDLE_TAG copies the HTML Tag and checks whether we
301
* have that tag in our table. If we might modify it,
302
* we continue to scan the tag, otherwise we simply copy the complete
303
* HTML stuff to the result buffer.
306
static inline void handle_tag(STD_PARA)
312
smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
313
for (i = 0; i < ctx->tag.len; i++)
314
ctx->tag.c[i] = tolower((int)(unsigned char)ctx->tag.c[i]);
315
if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS)
317
STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
320
static inline void handle_arg(STD_PARA)
323
smart_str_appendl(&ctx->arg, start, YYCURSOR - start);
326
static inline void handle_val(STD_PARA, char quotes, char type)
328
smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2);
329
tag_arg(ctx, quotes, type TSRMLS_CC);
332
static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen TSRMLS_DC)
339
smart_str_appendl(&ctx->buf, newdata, newlen);
341
YYCURSOR = ctx->buf.c;
342
YYLIMIT = ctx->buf.c + ctx->buf.len;
345
case STATE_PLAIN: goto state_plain;
346
case STATE_TAG: goto state_tag;
347
case STATE_NEXT_ARG: goto state_next_arg;
348
case STATE_ARG: goto state_arg;
349
case STATE_BEFORE_VAL: goto state_before_val;
350
case STATE_VAL: goto state_val;
363
unsigned int yyaccept;
364
static unsigned char yybm[] = {
365
128, 128, 128, 128, 128, 128, 128, 128,
366
128, 128, 128, 128, 128, 128, 128, 128,
367
128, 128, 128, 128, 128, 128, 128, 128,
368
128, 128, 128, 128, 128, 128, 128, 128,
369
128, 128, 128, 128, 128, 128, 128, 128,
370
128, 128, 128, 128, 128, 128, 128, 128,
371
128, 128, 128, 128, 128, 128, 128, 128,
372
128, 128, 128, 128, 0, 128, 128, 128,
373
128, 128, 128, 128, 128, 128, 128, 128,
374
128, 128, 128, 128, 128, 128, 128, 128,
375
128, 128, 128, 128, 128, 128, 128, 128,
376
128, 128, 128, 128, 128, 128, 128, 128,
377
128, 128, 128, 128, 128, 128, 128, 128,
378
128, 128, 128, 128, 128, 128, 128, 128,
379
128, 128, 128, 128, 128, 128, 128, 128,
380
128, 128, 128, 128, 128, 128, 128, 128,
381
128, 128, 128, 128, 128, 128, 128, 128,
382
128, 128, 128, 128, 128, 128, 128, 128,
383
128, 128, 128, 128, 128, 128, 128, 128,
384
128, 128, 128, 128, 128, 128, 128, 128,
385
128, 128, 128, 128, 128, 128, 128, 128,
386
128, 128, 128, 128, 128, 128, 128, 128,
387
128, 128, 128, 128, 128, 128, 128, 128,
388
128, 128, 128, 128, 128, 128, 128, 128,
389
128, 128, 128, 128, 128, 128, 128, 128,
390
128, 128, 128, 128, 128, 128, 128, 128,
391
128, 128, 128, 128, 128, 128, 128, 128,
392
128, 128, 128, 128, 128, 128, 128, 128,
393
128, 128, 128, 128, 128, 128, 128, 128,
394
128, 128, 128, 128, 128, 128, 128, 128,
395
128, 128, 128, 128, 128, 128, 128, 128,
396
128, 128, 128, 128, 128, 128, 128, 128,
401
if(YYLIMIT == YYCURSOR) YYFILL(1);
403
if(yybm[0+yych] & 128) {
410
#line 285 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
411
{ passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
414
if(YYLIMIT == YYCURSOR) YYFILL(1);
417
yy16: if(yybm[0+yych] & 128) {
422
#line 286 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
423
{ passthru(STD_ARGS); goto state_plain; }
426
#line 287 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
435
unsigned int yyaccept;
436
static unsigned char yybm[] = {
437
0, 0, 0, 0, 0, 0, 0, 0,
438
0, 0, 0, 0, 0, 0, 0, 0,
439
0, 0, 0, 0, 0, 0, 0, 0,
440
0, 0, 0, 0, 0, 0, 0, 0,
441
0, 0, 0, 0, 0, 0, 0, 0,
442
0, 0, 0, 0, 0, 0, 0, 0,
443
0, 0, 0, 0, 0, 0, 0, 0,
444
0, 0, 0, 0, 0, 0, 0, 0,
445
0, 128, 128, 128, 128, 128, 128, 128,
446
128, 128, 128, 128, 128, 128, 128, 128,
447
128, 128, 128, 128, 128, 128, 128, 128,
448
128, 128, 128, 0, 0, 0, 0, 0,
449
0, 128, 128, 128, 128, 128, 128, 128,
450
128, 128, 128, 128, 128, 128, 128, 128,
451
128, 128, 128, 128, 128, 128, 128, 128,
452
128, 128, 128, 0, 0, 0, 0, 0,
453
0, 0, 0, 0, 0, 0, 0, 0,
454
0, 0, 0, 0, 0, 0, 0, 0,
455
0, 0, 0, 0, 0, 0, 0, 0,
456
0, 0, 0, 0, 0, 0, 0, 0,
457
0, 0, 0, 0, 0, 0, 0, 0,
458
0, 0, 0, 0, 0, 0, 0, 0,
459
0, 0, 0, 0, 0, 0, 0, 0,
460
0, 0, 0, 0, 0, 0, 0, 0,
461
0, 0, 0, 0, 0, 0, 0, 0,
462
0, 0, 0, 0, 0, 0, 0, 0,
463
0, 0, 0, 0, 0, 0, 0, 0,
464
0, 0, 0, 0, 0, 0, 0, 0,
465
0, 0, 0, 0, 0, 0, 0, 0,
466
0, 0, 0, 0, 0, 0, 0, 0,
467
0, 0, 0, 0, 0, 0, 0, 0,
468
0, 0, 0, 0, 0, 0, 0, 0,
473
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
475
if(yych <= '@') goto yy22;
476
if(yych <= 'Z') goto yy20;
477
if(yych <= '`') goto yy22;
478
if(yych >= '{') goto yy22;
484
#line 292 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
485
{ handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
490
#line 293 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
491
{ passthru(STD_ARGS); goto state_plain_begin; }
494
if(YYLIMIT == YYCURSOR) YYFILL(1);
497
yy25: if(yybm[0+yych] & 128) {
502
#line 294 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
505
state_next_arg_begin:
506
STATE = STATE_NEXT_ARG;
514
unsigned int yyaccept;
515
static unsigned char yybm[] = {
516
0, 0, 0, 0, 0, 0, 0, 0,
517
0, 128, 128, 128, 0, 0, 0, 0,
518
0, 0, 0, 0, 0, 0, 0, 0,
519
0, 0, 0, 0, 0, 0, 0, 0,
520
128, 0, 0, 0, 0, 0, 0, 0,
521
0, 0, 0, 0, 0, 0, 0, 0,
522
0, 0, 0, 0, 0, 0, 0, 0,
523
0, 0, 0, 0, 0, 0, 0, 0,
524
0, 0, 0, 0, 0, 0, 0, 0,
525
0, 0, 0, 0, 0, 0, 0, 0,
526
0, 0, 0, 0, 0, 0, 0, 0,
527
0, 0, 0, 0, 0, 0, 0, 0,
528
0, 0, 0, 0, 0, 0, 0, 0,
529
0, 0, 0, 0, 0, 0, 0, 0,
530
0, 0, 0, 0, 0, 0, 0, 0,
531
0, 0, 0, 0, 0, 0, 0, 0,
532
0, 0, 0, 0, 0, 0, 0, 0,
533
0, 0, 0, 0, 0, 0, 0, 0,
534
0, 0, 0, 0, 0, 0, 0, 0,
535
0, 0, 0, 0, 0, 0, 0, 0,
536
0, 0, 0, 0, 0, 0, 0, 0,
537
0, 0, 0, 0, 0, 0, 0, 0,
538
0, 0, 0, 0, 0, 0, 0, 0,
539
0, 0, 0, 0, 0, 0, 0, 0,
540
0, 0, 0, 0, 0, 0, 0, 0,
541
0, 0, 0, 0, 0, 0, 0, 0,
542
0, 0, 0, 0, 0, 0, 0, 0,
543
0, 0, 0, 0, 0, 0, 0, 0,
544
0, 0, 0, 0, 0, 0, 0, 0,
545
0, 0, 0, 0, 0, 0, 0, 0,
546
0, 0, 0, 0, 0, 0, 0, 0,
547
0, 0, 0, 0, 0, 0, 0, 0,
552
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
556
if(yych <= 0x08) goto yy34;
559
if(yych == ' ') goto yy30;
564
if(yych <= '>') goto yy28;
565
if(yych <= '@') goto yy34;
568
if(yych <= '`') goto yy34;
569
if(yych <= 'z') goto yy32;
576
#line 302 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
577
{ passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
583
#line 303 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
584
{ passthru(STD_ARGS); goto state_next_arg; }
589
#line 304 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
590
{ --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
595
#line 305 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
596
{ passthru(STD_ARGS); goto state_plain_begin; }
599
if(YYLIMIT == YYCURSOR) YYFILL(1);
602
yy37: if(yybm[0+yych] & 128) {
607
#line 306 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
616
unsigned int yyaccept;
617
static unsigned char yybm[] = {
618
0, 0, 0, 0, 0, 0, 0, 0,
619
0, 0, 0, 0, 0, 0, 0, 0,
620
0, 0, 0, 0, 0, 0, 0, 0,
621
0, 0, 0, 0, 0, 0, 0, 0,
622
0, 0, 0, 0, 0, 0, 0, 0,
623
0, 0, 0, 0, 0, 128, 0, 0,
624
0, 0, 0, 0, 0, 0, 0, 0,
625
0, 0, 0, 0, 0, 0, 0, 0,
626
0, 128, 128, 128, 128, 128, 128, 128,
627
128, 128, 128, 128, 128, 128, 128, 128,
628
128, 128, 128, 128, 128, 128, 128, 128,
629
128, 128, 128, 0, 0, 0, 0, 0,
630
0, 128, 128, 128, 128, 128, 128, 128,
631
128, 128, 128, 128, 128, 128, 128, 128,
632
128, 128, 128, 128, 128, 128, 128, 128,
633
128, 128, 128, 0, 0, 0, 0, 0,
634
0, 0, 0, 0, 0, 0, 0, 0,
635
0, 0, 0, 0, 0, 0, 0, 0,
636
0, 0, 0, 0, 0, 0, 0, 0,
637
0, 0, 0, 0, 0, 0, 0, 0,
638
0, 0, 0, 0, 0, 0, 0, 0,
639
0, 0, 0, 0, 0, 0, 0, 0,
640
0, 0, 0, 0, 0, 0, 0, 0,
641
0, 0, 0, 0, 0, 0, 0, 0,
642
0, 0, 0, 0, 0, 0, 0, 0,
643
0, 0, 0, 0, 0, 0, 0, 0,
644
0, 0, 0, 0, 0, 0, 0, 0,
645
0, 0, 0, 0, 0, 0, 0, 0,
646
0, 0, 0, 0, 0, 0, 0, 0,
647
0, 0, 0, 0, 0, 0, 0, 0,
648
0, 0, 0, 0, 0, 0, 0, 0,
649
0, 0, 0, 0, 0, 0, 0, 0,
654
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
656
if(yych <= '@') goto yy42;
657
if(yych <= 'Z') goto yy40;
658
if(yych <= '`') goto yy42;
659
if(yych >= '{') goto yy42;
665
#line 311 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
666
{ passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
671
#line 312 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
672
{ passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; }
675
if(YYLIMIT == YYCURSOR) YYFILL(1);
678
yy45: if(yybm[0+yych] & 128) {
683
#line 313 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
692
unsigned int yyaccept;
693
static unsigned char yybm[] = {
694
0, 0, 0, 0, 0, 0, 0, 0,
695
0, 0, 0, 0, 0, 0, 0, 0,
696
0, 0, 0, 0, 0, 0, 0, 0,
697
0, 0, 0, 0, 0, 0, 0, 0,
698
128, 0, 0, 0, 0, 0, 0, 0,
699
0, 0, 0, 0, 0, 0, 0, 0,
700
0, 0, 0, 0, 0, 0, 0, 0,
701
0, 0, 0, 0, 0, 0, 0, 0,
702
0, 0, 0, 0, 0, 0, 0, 0,
703
0, 0, 0, 0, 0, 0, 0, 0,
704
0, 0, 0, 0, 0, 0, 0, 0,
705
0, 0, 0, 0, 0, 0, 0, 0,
706
0, 0, 0, 0, 0, 0, 0, 0,
707
0, 0, 0, 0, 0, 0, 0, 0,
708
0, 0, 0, 0, 0, 0, 0, 0,
709
0, 0, 0, 0, 0, 0, 0, 0,
710
0, 0, 0, 0, 0, 0, 0, 0,
711
0, 0, 0, 0, 0, 0, 0, 0,
712
0, 0, 0, 0, 0, 0, 0, 0,
713
0, 0, 0, 0, 0, 0, 0, 0,
714
0, 0, 0, 0, 0, 0, 0, 0,
715
0, 0, 0, 0, 0, 0, 0, 0,
716
0, 0, 0, 0, 0, 0, 0, 0,
717
0, 0, 0, 0, 0, 0, 0, 0,
718
0, 0, 0, 0, 0, 0, 0, 0,
719
0, 0, 0, 0, 0, 0, 0, 0,
720
0, 0, 0, 0, 0, 0, 0, 0,
721
0, 0, 0, 0, 0, 0, 0, 0,
722
0, 0, 0, 0, 0, 0, 0, 0,
723
0, 0, 0, 0, 0, 0, 0, 0,
724
0, 0, 0, 0, 0, 0, 0, 0,
725
0, 0, 0, 0, 0, 0, 0, 0,
730
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
732
if(yych == ' ') goto yy48;
733
if(yych == '=') goto yy50;
736
yych = *(YYMARKER = ++YYCURSOR);
737
if(yych == ' ') goto yy55;
738
if(yych == '=') goto yy53;
741
#line 319 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
742
{ --YYCURSOR; goto state_next_arg_begin; }
748
#line 318 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
749
{ passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
751
yy52: yych = *++YYCURSOR;
754
if(YYLIMIT == YYCURSOR) YYFILL(1);
757
yy54: if(yybm[0+yych] & 128) {
762
if(YYLIMIT == YYCURSOR) YYFILL(1);
765
yy56: if(yych == ' ') goto yy55;
766
if(yych == '=') goto yy53;
768
yy57: YYCURSOR = YYMARKER;
773
#line 320 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
783
unsigned int yyaccept;
784
static unsigned char yybm[] = {
785
248, 248, 248, 248, 248, 248, 248, 248,
786
248, 160, 160, 248, 248, 248, 248, 248,
787
248, 248, 248, 248, 248, 248, 248, 248,
788
248, 248, 248, 248, 248, 248, 248, 248,
789
160, 248, 56, 248, 248, 248, 248, 200,
790
248, 248, 248, 248, 248, 248, 248, 248,
791
248, 248, 248, 248, 248, 248, 248, 248,
792
248, 248, 248, 248, 248, 248, 0, 248,
793
248, 248, 248, 248, 248, 248, 248, 248,
794
248, 248, 248, 248, 248, 248, 248, 248,
795
248, 248, 248, 248, 248, 248, 248, 248,
796
248, 248, 248, 248, 248, 248, 248, 248,
797
248, 248, 248, 248, 248, 248, 248, 248,
798
248, 248, 248, 248, 248, 248, 248, 248,
799
248, 248, 248, 248, 248, 248, 248, 248,
800
248, 248, 248, 248, 248, 248, 248, 248,
801
248, 248, 248, 248, 248, 248, 248, 248,
802
248, 248, 248, 248, 248, 248, 248, 248,
803
248, 248, 248, 248, 248, 248, 248, 248,
804
248, 248, 248, 248, 248, 248, 248, 248,
805
248, 248, 248, 248, 248, 248, 248, 248,
806
248, 248, 248, 248, 248, 248, 248, 248,
807
248, 248, 248, 248, 248, 248, 248, 248,
808
248, 248, 248, 248, 248, 248, 248, 248,
809
248, 248, 248, 248, 248, 248, 248, 248,
810
248, 248, 248, 248, 248, 248, 248, 248,
811
248, 248, 248, 248, 248, 248, 248, 248,
812
248, 248, 248, 248, 248, 248, 248, 248,
813
248, 248, 248, 248, 248, 248, 248, 248,
814
248, 248, 248, 248, 248, 248, 248, 248,
815
248, 248, 248, 248, 248, 248, 248, 248,
816
248, 248, 248, 248, 248, 248, 248, 248,
821
if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
825
if(yych <= 0x08) goto yy63;
828
if(yych == ' ') goto yy64;
833
if(yych <= '"') goto yy60;
834
if(yych <= '&') goto yy63;
837
if(yych == '>') goto yy64;
842
yych = *(YYMARKER = ++YYCURSOR);
845
#line 328 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
846
{ handle_val(STD_ARGS, 0, '\0'); goto state_next_arg_begin; }
849
yych = *(YYMARKER = ++YYCURSOR);
851
yy63: yych = *++YYCURSOR;
856
#line 329 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
857
{ passthru(STD_ARGS); goto state_next_arg_begin; }
860
if(YYLIMIT == YYCURSOR) YYFILL(1);
863
yy67: if(yybm[0+yych] & 8) {
868
YYMARKER = ++YYCURSOR;
869
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
872
yy69: if(yybm[0+yych] & 16) {
875
if(yych <= '&') goto yy72;
876
if(yych >= '(') goto yy61;
879
if(yybm[0+(yych = *YYCURSOR)] & 8) {
885
#line 327 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
886
{ handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
889
if(YYLIMIT == YYCURSOR) YYFILL(1);
892
yy73: if(yybm[0+yych] & 32) {
895
if(yych <= '=') goto yy75;
897
yy74: YYCURSOR = YYMARKER;
901
yy75: yych = *++YYCURSOR;
904
YYMARKER = ++YYCURSOR;
905
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
908
yy77: if(yybm[0+yych] & 64) {
911
if(yych <= '!') goto yy80;
912
if(yych >= '#') goto yy61;
915
if(yybm[0+(yych = *YYCURSOR)] & 8) {
921
#line 326 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
922
{ handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
925
if(YYLIMIT == YYCURSOR) YYFILL(1);
928
yy81: if(yybm[0+yych] & 128) {
931
if(yych >= '>') goto yy74;
937
#line 330 "/usr/src/php/php_5_0/ext/standard/url_scanner_ex.re"
941
rest = YYLIMIT - start;
942
scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest));
943
/* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */
944
if (rest < 0) rest = 0;
946
if (rest) memmove(ctx->buf.c, start, rest);
950
char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen TSRMLS_DC)
952
smart_str surl = {0};
954
smart_str url_app = {0};
956
smart_str_setl(&surl, url, urllen);
958
smart_str_appends(&url_app, name);
959
smart_str_appendc(&url_app, '=');
960
smart_str_appends(&url_app, value);
962
append_modified_url(&surl, &buf, &url_app, PG(arg_separator).output);
965
if (newlen) *newlen = buf.len;
967
smart_str_free(&url_app);
973
static char *url_adapt_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush TSRMLS_DC)
975
url_adapt_state_ex_t *ctx;
978
ctx = &BG(url_adapt_state_ex);
980
xx_mainloop(ctx, src, srclen TSRMLS_CC);
982
*newlen = ctx->result.len;
983
if (!ctx->result.c) {
984
smart_str_appendl(&ctx->result, "", 0);
986
smart_str_0(&ctx->result);
988
smart_str_appendl(&ctx->result, ctx->buf.c, ctx->buf.len);
989
*newlen += ctx->buf.len;
990
smart_str_free(&ctx->buf);
992
retval = ctx->result.c;
993
ctx->result.c = NULL;
998
int php_url_scanner_ex_activate(TSRMLS_D)
1000
url_adapt_state_ex_t *ctx;
1002
ctx = &BG(url_adapt_state_ex);
1004
memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags));
1009
int php_url_scanner_ex_deactivate(TSRMLS_D)
1011
url_adapt_state_ex_t *ctx;
1013
ctx = &BG(url_adapt_state_ex);
1015
smart_str_free(&ctx->result);
1016
smart_str_free(&ctx->buf);
1017
smart_str_free(&ctx->tag);
1018
smart_str_free(&ctx->arg);
1023
static void php_url_scanner_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
1027
if (BG(url_adapt_state_ex).url_app.len != 0) {
1028
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & PHP_OUTPUT_HANDLER_END ? 1 : 0) TSRMLS_CC);
1029
if (sizeof(uint) < sizeof(size_t)) {
1033
*handled_output_len = len;
1034
} else if (BG(url_adapt_state_ex).url_app.len == 0) {
1035
url_adapt_state_ex_t *ctx = &BG(url_adapt_state_ex);
1037
smart_str_appendl(&ctx->result, ctx->buf.c, ctx->buf.len);
1038
smart_str_appendl(&ctx->result, output, output_len);
1040
*handled_output = ctx->result.c;
1041
*handled_output_len = ctx->buf.len + output_len;
1043
ctx->result.c = NULL;
1044
ctx->result.len = 0;
1045
smart_str_free(&ctx->buf);
1047
*handled_output = NULL;
1050
*handled_output = NULL;
1054
int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC)
1060
if (! BG(url_adapt_state_ex).active) {
1061
php_url_scanner_ex_activate(TSRMLS_C);
1062
php_ob_set_internal_handler(php_url_scanner_output_handler, 0, "URL-Rewriter", 1 TSRMLS_CC);
1063
BG(url_adapt_state_ex).active = 1;
1067
if (BG(url_adapt_state_ex).url_app.len != 0) {
1068
smart_str_appends(&BG(url_adapt_state_ex).url_app, PG(arg_separator).output);
1072
encoded = php_url_encode(value, value_len, &encoded_len);
1073
smart_str_setl(&val, encoded, encoded_len);
1075
smart_str_setl(&val, value, value_len);
1078
smart_str_appendl(&BG(url_adapt_state_ex).url_app, name, name_len);
1079
smart_str_appendc(&BG(url_adapt_state_ex).url_app, '=');
1080
smart_str_append(&BG(url_adapt_state_ex).url_app, &val);
1082
smart_str_appends(&BG(url_adapt_state_ex).form_app, "<input type=\"hidden\" name=\"");
1083
smart_str_appendl(&BG(url_adapt_state_ex).form_app, name, name_len);
1084
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" value=\"");
1085
smart_str_append(&BG(url_adapt_state_ex).form_app, &val);
1086
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" />");
1094
int php_url_scanner_reset_vars(TSRMLS_D)
1096
BG(url_adapt_state_ex).form_app.len = 0;
1097
BG(url_adapt_state_ex).url_app.len = 0;
1102
PHP_MINIT_FUNCTION(url_scanner)
1104
BG(url_adapt_state_ex).tags = NULL;
1106
BG(url_adapt_state_ex).form_app.c = BG(url_adapt_state_ex).url_app.c = 0;
1107
BG(url_adapt_state_ex).form_app.len = BG(url_adapt_state_ex).url_app.len = 0;
1109
REGISTER_INI_ENTRIES();
1113
PHP_MSHUTDOWN_FUNCTION(url_scanner)
1115
UNREGISTER_INI_ENTRIES();
1120
PHP_RINIT_FUNCTION(url_scanner)
1122
BG(url_adapt_state_ex).active = 0;
1127
PHP_RSHUTDOWN_FUNCTION(url_scanner)
1129
if (BG(url_adapt_state_ex).active) {
1130
php_url_scanner_ex_deactivate(TSRMLS_C);
1131
BG(url_adapt_state_ex).active = 0;
1134
smart_str_free(&BG(url_adapt_state_ex).form_app);
1135
smart_str_free(&BG(url_adapt_state_ex).url_app);