2013-07-17 15:07:26 +00:00
|
|
|
/* Generated by re2c 0.13.5 */
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 1 "ext/standard/url_scanner_ex.re"
|
2000-09-19 17:32:27 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2014-09-19 16:33:14 +00:00
|
|
|
| PHP Version 7 |
|
2000-09-19 17:32:27 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2015-01-15 15:27:30 +00:00
|
|
|
| Copyright (c) 1997-2015 The PHP Group |
|
2000-09-19 17:32:27 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2000-09-19 17:32:27 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2000-09-19 17:32:27 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2002-02-28 08:29:35 +00:00
|
|
|
| Author: Sascha Schumann <sascha@schumann.cx> |
|
2000-09-19 17:32:27 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2005-01-10 15:20:53 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2000-09-19 17:32:27 +00:00
|
|
|
#include "php.h"
|
|
|
|
|
2000-09-19 17:53:09 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2000-09-19 17:32:27 +00:00
|
|
|
#include <unistd.h>
|
2000-09-19 17:53:09 +00:00
|
|
|
#endif
|
2003-03-11 02:28:46 +00:00
|
|
|
#ifdef HAVE_LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif
|
2000-09-19 17:53:09 +00:00
|
|
|
|
2000-09-19 17:32:27 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
#include "php_ini.h"
|
2000-09-19 17:32:27 +00:00
|
|
|
#include "php_globals.h"
|
|
|
|
#define STATE_TAG SOME_OTHER_STATE_TAG
|
|
|
|
#include "basic_functions.h"
|
2002-05-04 17:15:09 +00:00
|
|
|
#include "url.h"
|
2000-09-19 17:32:27 +00:00
|
|
|
#undef STATE_TAG
|
|
|
|
|
|
|
|
#define url_scanner url_scanner_ex
|
|
|
|
|
2014-09-20 20:42:02 +00:00
|
|
|
#include "zend_smart_str.h"
|
2000-09-19 18:17:28 +00:00
|
|
|
|
2014-02-17 13:59:18 +00:00
|
|
|
static void tag_dtor(zval *zv)
|
|
|
|
{
|
|
|
|
free(Z_PTR_P(zv));
|
|
|
|
}
|
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
static PHP_INI_MH(OnUpdateTags)
|
|
|
|
{
|
|
|
|
url_adapt_state_ex_t *ctx;
|
|
|
|
char *key;
|
|
|
|
char *tmp;
|
2015-01-08 08:28:32 +00:00
|
|
|
char *lasts = NULL;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
ctx = &BG(url_adapt_state_ex);
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
tmp = estrndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
if (ctx->tags)
|
|
|
|
zend_hash_destroy(ctx->tags);
|
2011-07-28 10:52:45 +00:00
|
|
|
else {
|
2000-10-16 17:25:36 +00:00
|
|
|
ctx->tags = malloc(sizeof(HashTable));
|
2011-07-28 10:52:45 +00:00
|
|
|
if (!ctx->tags) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2013-01-01 08:28:54 +00:00
|
|
|
|
2014-02-17 13:59:18 +00:00
|
|
|
zend_hash_init(ctx->tags, 0, NULL, tag_dtor, 1);
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
for (key = php_strtok_r(tmp, ",", &lasts);
|
|
|
|
key;
|
|
|
|
key = php_strtok_r(NULL, ",", &lasts)) {
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
val = strchr(key, '=');
|
|
|
|
if (val) {
|
|
|
|
char *q;
|
2014-10-27 12:08:21 +00:00
|
|
|
size_t keylen;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
*val++ = '\0';
|
|
|
|
for (q = key; *q; q++)
|
|
|
|
*q = tolower(*q);
|
|
|
|
keylen = q - key;
|
|
|
|
/* key is stored withOUT NUL
|
|
|
|
val is stored WITH NUL */
|
2014-02-13 13:54:23 +00:00
|
|
|
zend_hash_str_add_mem(ctx->tags, key, keylen, val, strlen(val)+1);
|
2000-10-16 17:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
efree(tmp);
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
PHP_INI_BEGIN()
|
2002-09-25 12:15:42 +00:00
|
|
|
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)
|
2000-10-16 17:25:36 +00:00
|
|
|
PHP_INI_END()
|
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 107 "ext/standard/url_scanner_ex.re"
|
2001-07-04 15:30:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define YYFILL(n) goto done
|
|
|
|
#define YYCTYPE unsigned char
|
|
|
|
#define YYCURSOR p
|
|
|
|
#define YYLIMIT q
|
|
|
|
#define YYMARKER r
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2002-05-04 18:34:29 +00:00
|
|
|
static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator)
|
2000-09-19 17:32:27 +00:00
|
|
|
{
|
2001-09-11 07:52:55 +00:00
|
|
|
register const char *p, *q;
|
2000-09-20 02:04:19 +00:00
|
|
|
const char *bash = NULL;
|
2000-12-22 22:52:11 +00:00
|
|
|
const char *sep = "?";
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
q = (p = ZSTR_VAL(url->s)) + ZSTR_LEN(url->s);
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
scan:
|
2008-03-28 14:35:01 +00:00
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 123 "ext/standard/url_scanner_ex.c"
|
2005-06-28 23:16:49 +00:00
|
|
|
{
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCTYPE yych;
|
2007-10-10 09:27:13 +00:00
|
|
|
static const unsigned char yybm[] = {
|
2015-02-02 03:53:41 +00:00
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 0, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 0, 128, 128, 128, 128, 0,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
2007-10-10 09:27:13 +00:00
|
|
|
};
|
|
|
|
|
2008-03-28 14:35:01 +00:00
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
|
|
|
if (yybm[0+yych] & 128) {
|
|
|
|
goto yy8;
|
|
|
|
}
|
|
|
|
if (yych <= '9') goto yy6;
|
|
|
|
if (yych >= ';') goto yy4;
|
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 125 "ext/standard/url_scanner_ex.re"
|
2014-09-21 18:28:44 +00:00
|
|
|
{ smart_str_append_smart_str(dest, url); return; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 171 "ext/standard/url_scanner_ex.c"
|
2007-06-06 00:00:28 +00:00
|
|
|
yy4:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 126 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ sep = separator; goto scan; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 176 "ext/standard/url_scanner_ex.c"
|
2007-06-06 00:00:28 +00:00
|
|
|
yy6:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 127 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ bash = p - 1; goto done; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 181 "ext/standard/url_scanner_ex.c"
|
2007-06-06 00:00:28 +00:00
|
|
|
yy8:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
|
|
|
if (yybm[0+yych] & 128) {
|
|
|
|
goto yy8;
|
2007-10-10 09:27:13 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 128 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ goto scan; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 191 "ext/standard/url_scanner_ex.c"
|
2001-07-04 15:30:21 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 129 "ext/standard/url_scanner_ex.re"
|
2001-07-04 15:30:21 +00:00
|
|
|
|
|
|
|
done:
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
/* Don't modify URLs of the format "#mark" */
|
2015-06-30 01:05:24 +00:00
|
|
|
if (bash && bash - ZSTR_VAL(url->s) == 0) {
|
2014-09-21 18:28:44 +00:00
|
|
|
smart_str_append_smart_str(dest, url);
|
2000-10-16 17:25:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-09-26 11:00:39 +00:00
|
|
|
if (bash)
|
2015-06-30 01:05:24 +00:00
|
|
|
smart_str_appendl(dest, ZSTR_VAL(url->s), bash - ZSTR_VAL(url->s));
|
2000-09-20 08:06:01 +00:00
|
|
|
else
|
2014-09-21 18:28:44 +00:00
|
|
|
smart_str_append_smart_str(dest, url);
|
2000-09-20 08:06:01 +00:00
|
|
|
|
2002-05-04 18:34:29 +00:00
|
|
|
smart_str_appends(dest, sep);
|
2014-09-21 18:28:44 +00:00
|
|
|
smart_str_append_smart_str(dest, url_app);
|
2000-09-20 08:06:01 +00:00
|
|
|
|
|
|
|
if (bash)
|
|
|
|
smart_str_appendl(dest, bash, q - bash);
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
2001-07-04 15:30:21 +00:00
|
|
|
|
2001-09-09 14:38:12 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
#undef YYFILL
|
|
|
|
#undef YYCTYPE
|
|
|
|
#undef YYCURSOR
|
|
|
|
#undef YYLIMIT
|
|
|
|
#undef YYMARKER
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type)
|
2000-09-19 17:32:27 +00:00
|
|
|
{
|
|
|
|
char f = 0;
|
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
if (strncasecmp(ZSTR_VAL(ctx->arg.s), ctx->lookup_data, ZSTR_LEN(ctx->arg.s)) == 0)
|
2000-10-16 17:25:36 +00:00
|
|
|
f = 1;
|
|
|
|
|
2002-03-26 10:23:33 +00:00
|
|
|
if (quotes)
|
|
|
|
smart_str_appendc(&ctx->result, type);
|
2000-09-19 17:32:27 +00:00
|
|
|
if (f) {
|
2002-05-04 18:34:29 +00:00
|
|
|
append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output);
|
2000-09-20 08:06:01 +00:00
|
|
|
} else {
|
2014-09-21 18:28:44 +00:00
|
|
|
smart_str_append_smart_str(&ctx->result, &ctx->val);
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
2002-03-26 10:23:33 +00:00
|
|
|
if (quotes)
|
|
|
|
smart_str_appendc(&ctx->result, type);
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
2001-07-04 15:30:21 +00:00
|
|
|
STATE_PLAIN = 0,
|
2000-09-19 17:32:27 +00:00
|
|
|
STATE_TAG,
|
|
|
|
STATE_NEXT_ARG,
|
|
|
|
STATE_ARG,
|
2000-09-20 01:15:10 +00:00
|
|
|
STATE_BEFORE_VAL,
|
|
|
|
STATE_VAL
|
2000-09-19 17:32:27 +00:00
|
|
|
};
|
|
|
|
|
2000-09-20 01:15:10 +00:00
|
|
|
#define YYFILL(n) goto stop
|
2000-10-04 18:06:20 +00:00
|
|
|
#define YYCTYPE unsigned char
|
2000-09-20 01:15:10 +00:00
|
|
|
#define YYCURSOR xp
|
|
|
|
#define YYLIMIT end
|
|
|
|
#define YYMARKER q
|
|
|
|
#define STATE ctx->state
|
|
|
|
|
2014-12-14 13:07:59 +00:00
|
|
|
#define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR
|
|
|
|
#define STD_ARGS ctx, start, xp
|
2000-12-04 12:26:53 +00:00
|
|
|
|
2002-09-25 12:15:42 +00:00
|
|
|
#if SCANNER_DEBUG
|
|
|
|
#define scdebug(x) printf x
|
|
|
|
#else
|
|
|
|
#define scdebug(x)
|
|
|
|
#endif
|
|
|
|
|
2015-01-03 09:22:58 +00:00
|
|
|
static inline void passthru(STD_PARA)
|
2000-12-04 12:26:53 +00:00
|
|
|
{
|
2002-09-25 12:15:42 +00:00
|
|
|
scdebug(("appending %d chars, starting with %c\n", YYCURSOR-start, *start));
|
2000-12-04 12:26:53 +00:00
|
|
|
smart_str_appendl(&ctx->result, start, YYCURSOR - start);
|
2000-09-20 01:15:10 +00:00
|
|
|
}
|
|
|
|
|
2002-09-25 12:15:42 +00:00
|
|
|
/*
|
|
|
|
* This function appends a hidden input field after a <form> or
|
|
|
|
* <fieldset>. The latter is important for XHTML.
|
|
|
|
*/
|
|
|
|
|
2015-01-03 09:22:58 +00:00
|
|
|
static void handle_form(STD_PARA)
|
2000-12-04 12:26:53 +00:00
|
|
|
{
|
2002-09-25 12:15:42 +00:00
|
|
|
int doit = 0;
|
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
if (ZSTR_LEN(ctx->form_app.s) > 0) {
|
|
|
|
switch (ZSTR_LEN(ctx->tag.s)) {
|
2007-10-10 00:34:40 +00:00
|
|
|
case sizeof("form") - 1:
|
2015-06-30 01:05:24 +00:00
|
|
|
if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "form", sizeof("form") - 1)) {
|
2015-01-03 09:22:58 +00:00
|
|
|
doit = 1;
|
2007-10-10 00:34:40 +00:00
|
|
|
}
|
2014-03-30 09:53:17 +00:00
|
|
|
if (doit && ctx->val.s && ctx->lookup_data && *ctx->lookup_data) {
|
2015-06-30 01:05:24 +00:00
|
|
|
char *e, *p = (char *)zend_memnstr(ZSTR_VAL(ctx->val.s), "://", sizeof("://") - 1, ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s));
|
2007-10-10 00:34:40 +00:00
|
|
|
if (p) {
|
2015-06-30 01:05:24 +00:00
|
|
|
e = memchr(p, '/', (ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s)) - p);
|
2007-10-10 00:34:40 +00:00
|
|
|
if (!e) {
|
2015-06-30 01:05:24 +00:00
|
|
|
e = ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s);
|
2007-10-10 00:34:40 +00:00
|
|
|
}
|
|
|
|
if ((e - p) && strncasecmp(p, ctx->lookup_data, (e - p))) {
|
|
|
|
doit = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case sizeof("fieldset") - 1:
|
2015-06-30 01:05:24 +00:00
|
|
|
if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "fieldset", sizeof("fieldset") - 1)) {
|
2015-01-03 09:22:58 +00:00
|
|
|
doit = 1;
|
2007-10-10 00:34:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-09-25 12:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (doit)
|
2014-09-21 18:28:44 +00:00
|
|
|
smart_str_append_smart_str(&ctx->result, &ctx->form_app);
|
2000-12-04 12:26:53 +00:00
|
|
|
}
|
2000-09-20 01:15:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-01-03 09:22:58 +00:00
|
|
|
* HANDLE_TAG copies the HTML Tag and checks whether we
|
2000-09-20 01:15:10 +00:00
|
|
|
* have that tag in our table. If we might modify it,
|
|
|
|
* we continue to scan the tag, otherwise we simply copy the complete
|
|
|
|
* HTML stuff to the result buffer.
|
|
|
|
*/
|
|
|
|
|
2015-01-03 09:22:58 +00:00
|
|
|
static inline void handle_tag(STD_PARA)
|
2000-12-04 12:26:53 +00:00
|
|
|
{
|
|
|
|
int ok = 0;
|
2010-09-23 03:45:36 +00:00
|
|
|
unsigned int i;
|
2000-12-04 12:26:53 +00:00
|
|
|
|
2014-03-18 07:18:40 +00:00
|
|
|
if (ctx->tag.s) {
|
2015-06-30 01:05:24 +00:00
|
|
|
ZSTR_LEN(ctx->tag.s) = 0;
|
2014-03-18 07:18:40 +00:00
|
|
|
}
|
2000-12-04 12:26:53 +00:00
|
|
|
smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
|
2015-06-30 01:05:24 +00:00
|
|
|
for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++)
|
|
|
|
ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
|
2014-02-18 09:42:46 +00:00
|
|
|
/* intentionally using str_find here, in case the hash value is set, but the string val is changed later */
|
2015-06-30 01:05:24 +00:00
|
|
|
if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL)
|
2000-12-04 12:26:53 +00:00
|
|
|
ok = 1;
|
|
|
|
STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
|
2000-09-20 01:15:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-03 09:22:58 +00:00
|
|
|
static inline void handle_arg(STD_PARA)
|
2000-12-04 12:26:53 +00:00
|
|
|
{
|
2014-03-18 07:18:40 +00:00
|
|
|
if (ctx->arg.s) {
|
2015-06-30 01:05:24 +00:00
|
|
|
ZSTR_LEN(ctx->arg.s) = 0;
|
2014-03-18 07:18:40 +00:00
|
|
|
}
|
2000-12-04 12:26:53 +00:00
|
|
|
smart_str_appendl(&ctx->arg, start, YYCURSOR - start);
|
2000-09-20 01:15:10 +00:00
|
|
|
}
|
2000-12-04 12:26:53 +00:00
|
|
|
|
2015-01-03 09:22:58 +00:00
|
|
|
static inline void handle_val(STD_PARA, char quotes, char type)
|
2000-12-04 12:26:53 +00:00
|
|
|
{
|
|
|
|
smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2);
|
2014-12-13 22:06:14 +00:00
|
|
|
tag_arg(ctx, quotes, type);
|
2000-09-20 01:15:10 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen)
|
2000-09-19 17:32:27 +00:00
|
|
|
{
|
2000-09-20 01:15:10 +00:00
|
|
|
char *end, *q;
|
|
|
|
char *xp;
|
|
|
|
char *start;
|
2014-10-27 12:08:21 +00:00
|
|
|
size_t rest;
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2000-09-20 01:15:10 +00:00
|
|
|
smart_str_appendl(&ctx->buf, newdata, newlen);
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
YYCURSOR = ZSTR_VAL(ctx->buf.s);
|
|
|
|
YYLIMIT = ZSTR_VAL(ctx->buf.s) + ZSTR_LEN(ctx->buf.s);
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
switch (STATE) {
|
|
|
|
case STATE_PLAIN: goto state_plain;
|
|
|
|
case STATE_TAG: goto state_tag;
|
|
|
|
case STATE_NEXT_ARG: goto state_next_arg;
|
|
|
|
case STATE_ARG: goto state_arg;
|
|
|
|
case STATE_BEFORE_VAL: goto state_before_val;
|
|
|
|
case STATE_VAL: goto state_val;
|
|
|
|
}
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-09-19 20:19:03 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
state_plain_begin:
|
|
|
|
STATE = STATE_PLAIN;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
state_plain:
|
|
|
|
start = YYCURSOR;
|
2008-03-28 14:35:01 +00:00
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 378 "ext/standard/url_scanner_ex.c"
|
2005-06-28 23:16:49 +00:00
|
|
|
{
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCTYPE yych;
|
2007-10-10 09:27:13 +00:00
|
|
|
static const unsigned char yybm[] = {
|
2015-02-02 03:53:41 +00:00
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 0, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
2007-10-10 09:27:13 +00:00
|
|
|
};
|
2008-03-28 14:35:01 +00:00
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
|
|
|
if (yybm[0+yych] & 128) {
|
|
|
|
goto yy15;
|
|
|
|
}
|
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 313 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 423 "ext/standard/url_scanner_ex.c"
|
2007-06-06 00:00:28 +00:00
|
|
|
yy15:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
|
|
|
if (yybm[0+yych] & 128) {
|
|
|
|
goto yy15;
|
2007-10-10 09:27:13 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 314 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); goto state_plain; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 433 "ext/standard/url_scanner_ex.c"
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 315 "ext/standard/url_scanner_ex.re"
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
|
2015-01-03 09:22:58 +00:00
|
|
|
state_tag:
|
2001-07-04 15:30:21 +00:00
|
|
|
start = YYCURSOR;
|
2008-03-28 14:35:01 +00:00
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 441 "ext/standard/url_scanner_ex.c"
|
2005-06-28 23:16:49 +00:00
|
|
|
{
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCTYPE yych;
|
2007-10-10 09:27:13 +00:00
|
|
|
static const unsigned char yybm[] = {
|
2015-02-02 03:53:41 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 128, 0, 0, 0, 0, 0,
|
|
|
|
0, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 0, 0, 0, 0, 0,
|
|
|
|
0, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2007-10-10 09:27:13 +00:00
|
|
|
};
|
2008-03-28 14:35:01 +00:00
|
|
|
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
|
|
|
|
yych = *YYCURSOR;
|
|
|
|
if (yych <= '@') {
|
|
|
|
if (yych != ':') goto yy22;
|
|
|
|
} else {
|
|
|
|
if (yych <= 'Z') goto yy20;
|
|
|
|
if (yych <= '`') goto yy22;
|
|
|
|
if (yych >= '{') goto yy22;
|
|
|
|
}
|
2007-06-06 00:00:28 +00:00
|
|
|
yy20:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
yych = *YYCURSOR;
|
|
|
|
goto yy25;
|
2001-07-04 15:30:21 +00:00
|
|
|
yy21:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 320 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 494 "ext/standard/url_scanner_ex.c"
|
2007-06-06 00:00:28 +00:00
|
|
|
yy22:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 321 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); goto state_plain_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 499 "ext/standard/url_scanner_ex.c"
|
2007-06-06 00:00:28 +00:00
|
|
|
yy24:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
2007-06-06 00:00:28 +00:00
|
|
|
yy25:
|
2008-03-28 14:35:01 +00:00
|
|
|
if (yybm[0+yych] & 128) {
|
|
|
|
goto yy24;
|
2005-04-14 22:38:29 +00:00
|
|
|
}
|
2008-03-28 14:35:01 +00:00
|
|
|
goto yy21;
|
2005-06-28 23:16:49 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 322 "ext/standard/url_scanner_ex.re"
|
2000-09-20 01:15:10 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
|
|
|
|
state_next_arg_begin:
|
|
|
|
STATE = STATE_NEXT_ARG;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
state_next_arg:
|
|
|
|
start = YYCURSOR;
|
2008-03-28 14:35:01 +00:00
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 519 "ext/standard/url_scanner_ex.c"
|
2005-06-28 23:16:49 +00:00
|
|
|
{
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCTYPE yych;
|
2007-10-10 09:27:13 +00:00
|
|
|
static const unsigned char yybm[] = {
|
2015-02-02 03:53:41 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 128, 128, 128, 0, 128, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
128, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2007-10-10 09:27:13 +00:00
|
|
|
};
|
2008-03-28 14:35:01 +00:00
|
|
|
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= '.') {
|
2008-03-28 14:35:01 +00:00
|
|
|
if (yych <= '\f') {
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= 0x08) goto yy36;
|
|
|
|
if (yych <= '\v') goto yy32;
|
|
|
|
goto yy36;
|
2007-10-10 09:27:13 +00:00
|
|
|
} else {
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= '\r') goto yy32;
|
|
|
|
if (yych == ' ') goto yy32;
|
|
|
|
goto yy36;
|
2007-10-10 09:27:13 +00:00
|
|
|
}
|
2008-03-28 14:35:01 +00:00
|
|
|
} else {
|
|
|
|
if (yych <= '@') {
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= '/') goto yy28;
|
|
|
|
if (yych == '>') goto yy30;
|
|
|
|
goto yy36;
|
2008-03-28 14:35:01 +00:00
|
|
|
} else {
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= 'Z') goto yy34;
|
|
|
|
if (yych <= '`') goto yy36;
|
|
|
|
if (yych <= 'z') goto yy34;
|
|
|
|
goto yy36;
|
2008-03-28 14:35:01 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-17 15:28:01 +00:00
|
|
|
yy28:
|
|
|
|
++YYCURSOR;
|
|
|
|
if ((yych = *YYCURSOR) == '>') goto yy39;
|
|
|
|
yy29:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 333 "ext/standard/url_scanner_ex.re"
|
2013-07-17 15:28:01 +00:00
|
|
|
{ passthru(STD_ARGS); goto state_plain_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 586 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy30:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
yy31:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 330 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 592 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy32:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy38;
|
|
|
|
yy33:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 331 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); goto state_next_arg; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 600 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy34:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 332 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 605 "ext/standard/url_scanner_ex.c"
|
2007-06-06 00:00:28 +00:00
|
|
|
yy36:
|
2013-07-17 15:28:01 +00:00
|
|
|
yych = *++YYCURSOR;
|
|
|
|
goto yy29;
|
|
|
|
yy37:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
yy38:
|
2008-03-28 14:35:01 +00:00
|
|
|
if (yybm[0+yych] & 128) {
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy37;
|
2005-04-14 22:38:29 +00:00
|
|
|
}
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy33;
|
|
|
|
yy39:
|
|
|
|
++YYCURSOR;
|
|
|
|
yych = *YYCURSOR;
|
2008-03-28 14:35:01 +00:00
|
|
|
goto yy31;
|
2005-06-28 23:16:49 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 334 "ext/standard/url_scanner_ex.re"
|
2000-09-19 17:32:27 +00:00
|
|
|
|
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
state_arg:
|
|
|
|
start = YYCURSOR;
|
2008-03-28 14:35:01 +00:00
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 629 "ext/standard/url_scanner_ex.c"
|
2005-06-28 23:16:49 +00:00
|
|
|
{
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCTYPE yych;
|
2007-10-10 09:27:13 +00:00
|
|
|
static const unsigned char yybm[] = {
|
2015-02-02 03:53:41 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 128, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 0, 0, 0, 0, 0,
|
|
|
|
0, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 128, 128, 128, 128, 128,
|
|
|
|
128, 128, 128, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2007-10-10 09:27:13 +00:00
|
|
|
};
|
2008-03-28 14:35:01 +00:00
|
|
|
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= '@') goto yy44;
|
|
|
|
if (yych <= 'Z') goto yy42;
|
|
|
|
if (yych <= '`') goto yy44;
|
|
|
|
if (yych >= '{') goto yy44;
|
|
|
|
yy42:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy47;
|
|
|
|
yy43:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 339 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 679 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy44:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 340 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 684 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy46:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
yy47:
|
2008-03-28 14:35:01 +00:00
|
|
|
if (yybm[0+yych] & 128) {
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy46;
|
2005-04-14 22:38:29 +00:00
|
|
|
}
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy43;
|
2005-06-28 23:16:49 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 341 "ext/standard/url_scanner_ex.re"
|
2000-09-19 17:32:27 +00:00
|
|
|
|
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
state_before_val:
|
|
|
|
start = YYCURSOR;
|
2008-03-28 14:35:01 +00:00
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 701 "ext/standard/url_scanner_ex.c"
|
2005-06-28 23:16:49 +00:00
|
|
|
{
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCTYPE yych;
|
2007-10-10 09:27:13 +00:00
|
|
|
static const unsigned char yybm[] = {
|
2015-02-02 03:53:41 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
128, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2007-10-10 09:27:13 +00:00
|
|
|
};
|
2008-03-28 14:35:01 +00:00
|
|
|
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych == ' ') goto yy50;
|
|
|
|
if (yych == '=') goto yy52;
|
|
|
|
goto yy54;
|
|
|
|
yy50:
|
2008-03-28 14:35:01 +00:00
|
|
|
yych = *(YYMARKER = ++YYCURSOR);
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych == ' ') goto yy57;
|
|
|
|
if (yych == '=') goto yy55;
|
|
|
|
yy51:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 347 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ --YYCURSOR; goto state_next_arg_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 750 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy52:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy56;
|
|
|
|
yy53:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 346 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 758 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy54:
|
2008-03-28 14:35:01 +00:00
|
|
|
yych = *++YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy51;
|
|
|
|
yy55:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
yy56:
|
2008-03-28 14:35:01 +00:00
|
|
|
if (yybm[0+yych] & 128) {
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy55;
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy53;
|
|
|
|
yy57:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych == ' ') goto yy57;
|
|
|
|
if (yych == '=') goto yy55;
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCURSOR = YYMARKER;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy51;
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 348 "ext/standard/url_scanner_ex.re"
|
2001-07-04 15:30:21 +00:00
|
|
|
|
2000-09-19 17:32:27 +00:00
|
|
|
|
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
state_val:
|
|
|
|
start = YYCURSOR;
|
2008-03-28 14:35:01 +00:00
|
|
|
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 787 "ext/standard/url_scanner_ex.c"
|
2005-06-28 23:16:49 +00:00
|
|
|
{
|
2008-03-28 14:35:01 +00:00
|
|
|
YYCTYPE yych;
|
2007-10-10 09:27:13 +00:00
|
|
|
static const unsigned char yybm[] = {
|
2015-02-02 03:53:41 +00:00
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 192, 192, 224, 224, 192, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
192, 224, 64, 224, 224, 224, 224, 128,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 0, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
|
|
|
224, 224, 224, 224, 224, 224, 224, 224,
|
2007-10-10 09:27:13 +00:00
|
|
|
};
|
2013-07-17 15:07:26 +00:00
|
|
|
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
|
2008-03-28 14:35:01 +00:00
|
|
|
yych = *YYCURSOR;
|
|
|
|
if (yych <= ' ') {
|
|
|
|
if (yych <= '\f') {
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= 0x08) goto yy65;
|
|
|
|
if (yych <= '\n') goto yy67;
|
2013-07-17 15:07:26 +00:00
|
|
|
goto yy65;
|
2013-07-17 15:28:01 +00:00
|
|
|
} else {
|
|
|
|
if (yych <= '\r') goto yy67;
|
|
|
|
if (yych <= 0x1F) goto yy65;
|
|
|
|
goto yy67;
|
2008-03-28 14:35:01 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (yych <= '&') {
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych != '"') goto yy65;
|
2007-10-10 09:27:13 +00:00
|
|
|
} else {
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= '\'') goto yy64;
|
|
|
|
if (yych == '>') goto yy67;
|
|
|
|
goto yy65;
|
2007-10-10 09:27:13 +00:00
|
|
|
}
|
2008-03-28 14:35:01 +00:00
|
|
|
}
|
|
|
|
yych = *(YYMARKER = ++YYCURSOR);
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych != '>') goto yy76;
|
|
|
|
yy63:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 357 "ext/standard/url_scanner_ex.re"
|
2013-07-17 15:07:26 +00:00
|
|
|
{ passthru(STD_ARGS); goto state_next_arg_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 850 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy64:
|
2008-03-28 14:35:01 +00:00
|
|
|
yych = *(YYMARKER = ++YYCURSOR);
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych == '>') goto yy63;
|
|
|
|
goto yy71;
|
|
|
|
yy65:
|
2013-07-17 15:07:26 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy69;
|
|
|
|
yy66:
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 356 "ext/standard/url_scanner_ex.re"
|
2013-07-17 15:07:26 +00:00
|
|
|
{ handle_val(STD_ARGS, 0, ' '); goto state_next_arg_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 862 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy67:
|
2013-07-17 15:07:26 +00:00
|
|
|
yych = *++YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy63;
|
|
|
|
yy68:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
yy69:
|
2013-07-17 15:07:26 +00:00
|
|
|
if (yybm[0+yych] & 32) {
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy68;
|
2008-03-28 14:35:01 +00:00
|
|
|
}
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy66;
|
|
|
|
yy70:
|
2013-07-17 15:07:26 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
2008-03-28 14:35:01 +00:00
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
yy71:
|
2013-07-17 15:07:26 +00:00
|
|
|
if (yybm[0+yych] & 64) {
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy70;
|
2008-03-28 14:35:01 +00:00
|
|
|
}
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych <= '=') goto yy73;
|
|
|
|
yy72:
|
2013-07-17 15:07:26 +00:00
|
|
|
YYCURSOR = YYMARKER;
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy63;
|
|
|
|
yy73:
|
2013-07-17 15:07:26 +00:00
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 355 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 891 "ext/standard/url_scanner_ex.c"
|
2013-07-17 15:28:01 +00:00
|
|
|
yy75:
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
|
|
|
if (YYLIMIT <= YYCURSOR) YYFILL(1);
|
|
|
|
yych = *YYCURSOR;
|
2013-07-17 15:28:01 +00:00
|
|
|
yy76:
|
2013-07-17 15:07:26 +00:00
|
|
|
if (yybm[0+yych] & 128) {
|
2013-07-17 15:28:01 +00:00
|
|
|
goto yy75;
|
2008-03-28 14:35:01 +00:00
|
|
|
}
|
2013-07-17 15:28:01 +00:00
|
|
|
if (yych >= '>') goto yy72;
|
2008-03-28 14:35:01 +00:00
|
|
|
++YYCURSOR;
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 354 "ext/standard/url_scanner_ex.re"
|
2008-03-28 14:35:01 +00:00
|
|
|
{ handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 904 "ext/standard/url_scanner_ex.c"
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
2014-08-24 00:35:34 +00:00
|
|
|
#line 358 "ext/standard/url_scanner_ex.re"
|
2000-09-19 17:32:27 +00:00
|
|
|
|
|
|
|
|
2000-09-20 01:15:10 +00:00
|
|
|
stop:
|
2014-10-27 12:08:21 +00:00
|
|
|
if (YYLIMIT < start) {
|
2015-01-03 09:22:58 +00:00
|
|
|
/* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */
|
2014-10-27 12:08:21 +00:00
|
|
|
rest = 0;
|
|
|
|
} else {
|
|
|
|
rest = YYLIMIT - start;
|
|
|
|
scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest));
|
|
|
|
}
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
if (rest) memmove(ZSTR_VAL(ctx->buf.s), start, rest);
|
|
|
|
ZSTR_LEN(ctx->buf.s) = rest;
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 03:53:41 +00:00
|
|
|
|
|
|
|
PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen, int urlencode)
|
2002-05-05 16:39:49 +00:00
|
|
|
{
|
2014-02-18 09:42:46 +00:00
|
|
|
char *result;
|
2002-05-05 16:39:49 +00:00
|
|
|
smart_str surl = {0};
|
|
|
|
smart_str buf = {0};
|
|
|
|
smart_str url_app = {0};
|
2015-02-02 03:53:41 +00:00
|
|
|
zend_string *encoded;
|
2002-05-05 16:39:49 +00:00
|
|
|
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str_appendl(&surl, url, urllen);
|
2002-05-05 16:39:49 +00:00
|
|
|
|
2015-02-02 03:53:41 +00:00
|
|
|
if (urlencode) {
|
|
|
|
encoded = php_raw_url_encode(name, strlen(name));
|
2015-06-30 01:05:24 +00:00
|
|
|
smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
|
2015-02-02 03:53:41 +00:00
|
|
|
zend_string_free(encoded);
|
|
|
|
} else {
|
|
|
|
smart_str_appends(&url_app, name);
|
|
|
|
}
|
2002-05-05 16:39:49 +00:00
|
|
|
smart_str_appendc(&url_app, '=');
|
2015-02-02 03:53:41 +00:00
|
|
|
if (urlencode) {
|
|
|
|
encoded = php_raw_url_encode(value, strlen(value));
|
2015-06-30 01:05:24 +00:00
|
|
|
smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
|
2015-02-02 03:53:41 +00:00
|
|
|
zend_string_free(encoded);
|
|
|
|
} else {
|
|
|
|
smart_str_appends(&url_app, value);
|
|
|
|
}
|
2002-05-05 16:39:49 +00:00
|
|
|
|
|
|
|
append_modified_url(&surl, &buf, &url_app, PG(arg_separator).output);
|
|
|
|
|
|
|
|
smart_str_0(&buf);
|
2015-06-30 01:05:24 +00:00
|
|
|
if (newlen) *newlen = ZSTR_LEN(buf.s);
|
|
|
|
result = estrndup(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s));
|
2002-05-05 16:39:49 +00:00
|
|
|
|
|
|
|
smart_str_free(&url_app);
|
2014-02-18 09:42:46 +00:00
|
|
|
smart_str_free(&buf);
|
2002-05-05 16:39:49 +00:00
|
|
|
|
2014-02-18 09:42:46 +00:00
|
|
|
return result;
|
2002-05-05 16:39:49 +00:00
|
|
|
}
|
|
|
|
|
2001-07-04 15:30:21 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
static char *url_adapt_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush)
|
2000-09-19 17:32:27 +00:00
|
|
|
{
|
2000-09-20 01:15:10 +00:00
|
|
|
url_adapt_state_ex_t *ctx;
|
2001-08-27 00:23:55 +00:00
|
|
|
char *retval;
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2000-09-20 01:15:10 +00:00
|
|
|
ctx = &BG(url_adapt_state_ex);
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
xx_mainloop(ctx, src, srclen);
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2014-02-18 09:42:46 +00:00
|
|
|
if (!ctx->result.s) {
|
2001-07-04 15:30:21 +00:00
|
|
|
smart_str_appendl(&ctx->result, "", 0);
|
2014-03-18 07:18:40 +00:00
|
|
|
*newlen = 0;
|
|
|
|
} else {
|
2015-06-30 01:05:24 +00:00
|
|
|
*newlen = ZSTR_LEN(ctx->result.s);
|
2001-08-25 15:57:42 +00:00
|
|
|
}
|
2000-09-20 08:40:33 +00:00
|
|
|
smart_str_0(&ctx->result);
|
2001-08-25 15:57:42 +00:00
|
|
|
if (do_flush) {
|
2014-09-21 18:47:07 +00:00
|
|
|
smart_str_append(&ctx->result, ctx->buf.s);
|
2015-06-30 01:05:24 +00:00
|
|
|
*newlen += ZSTR_LEN(ctx->buf.s);
|
2001-08-27 00:23:55 +00:00
|
|
|
smart_str_free(&ctx->buf);
|
2014-03-18 07:18:40 +00:00
|
|
|
smart_str_free(&ctx->val);
|
2001-08-25 15:57:42 +00:00
|
|
|
}
|
2015-06-30 01:05:24 +00:00
|
|
|
retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
|
2014-02-18 09:42:46 +00:00
|
|
|
smart_str_free(&ctx->result);
|
2001-08-27 00:23:55 +00:00
|
|
|
return retval;
|
2000-09-19 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
static int php_url_scanner_ex_activate(void)
|
2000-09-19 17:32:27 +00:00
|
|
|
{
|
2000-09-20 01:15:10 +00:00
|
|
|
url_adapt_state_ex_t *ctx;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-09-20 01:15:10 +00:00
|
|
|
ctx = &BG(url_adapt_state_ex);
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags));
|
2000-09-19 17:32:27 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
static int php_url_scanner_ex_deactivate(void)
|
2000-09-19 17:32:27 +00:00
|
|
|
{
|
2000-09-20 01:15:10 +00:00
|
|
|
url_adapt_state_ex_t *ctx;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2000-09-20 01:15:10 +00:00
|
|
|
ctx = &BG(url_adapt_state_ex);
|
2000-09-19 17:32:27 +00:00
|
|
|
|
2000-09-20 01:15:10 +00:00
|
|
|
smart_str_free(&ctx->result);
|
|
|
|
smart_str_free(&ctx->buf);
|
2000-09-20 08:13:45 +00:00
|
|
|
smart_str_free(&ctx->tag);
|
|
|
|
smart_str_free(&ctx->arg);
|
2000-09-19 17:32:27 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
static void php_url_scanner_output_handler(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode)
|
2002-05-03 08:32:03 +00:00
|
|
|
{
|
2003-03-11 02:28:46 +00:00
|
|
|
size_t len;
|
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
if (ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) != 0) {
|
2014-12-13 22:06:14 +00:00
|
|
|
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0));
|
2003-03-11 02:28:46 +00:00
|
|
|
if (sizeof(uint) < sizeof(size_t)) {
|
|
|
|
if (len > UINT_MAX)
|
|
|
|
len = UINT_MAX;
|
|
|
|
}
|
|
|
|
*handled_output_len = len;
|
2015-06-30 01:05:24 +00:00
|
|
|
} else if (ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) == 0) {
|
2004-07-23 02:05:49 +00:00
|
|
|
url_adapt_state_ex_t *ctx = &BG(url_adapt_state_ex);
|
2015-06-30 01:05:24 +00:00
|
|
|
if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) {
|
2014-09-21 18:47:07 +00:00
|
|
|
smart_str_append(&ctx->result, ctx->buf.s);
|
2004-07-23 02:05:49 +00:00
|
|
|
smart_str_appendl(&ctx->result, output, output_len);
|
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
*handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
|
|
|
|
*handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len;
|
2004-07-23 02:05:49 +00:00
|
|
|
|
|
|
|
smart_str_free(&ctx->buf);
|
2014-02-18 09:42:46 +00:00
|
|
|
smart_str_free(&ctx->result);
|
2004-07-23 02:05:49 +00:00
|
|
|
} else {
|
2011-05-24 05:06:53 +00:00
|
|
|
*handled_output = estrndup(output, *handled_output_len = output_len);
|
2004-07-23 02:05:49 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*handled_output = NULL;
|
|
|
|
}
|
2002-05-03 08:32:03 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int urlencode)
|
2002-05-03 08:32:03 +00:00
|
|
|
{
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str sname = {0};
|
|
|
|
smart_str svalue = {0};
|
2014-03-03 08:34:43 +00:00
|
|
|
zend_string *encoded;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2014-03-18 07:18:40 +00:00
|
|
|
if (!BG(url_adapt_state_ex).active) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_url_scanner_ex_activate();
|
|
|
|
php_output_start_internal(ZEND_STRL("URL-Rewriter"), php_url_scanner_output_handler, 0, PHP_OUTPUT_HANDLER_STDFLAGS);
|
2002-05-03 08:32:03 +00:00
|
|
|
BG(url_adapt_state_ex).active = 1;
|
|
|
|
}
|
|
|
|
|
2015-06-30 01:05:24 +00:00
|
|
|
if (BG(url_adapt_state_ex).url_app.s && ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) != 0) {
|
2002-05-04 18:34:29 +00:00
|
|
|
smart_str_appends(&BG(url_adapt_state_ex).url_app, PG(arg_separator).output);
|
|
|
|
}
|
2002-05-03 08:32:03 +00:00
|
|
|
|
|
|
|
if (urlencode) {
|
2015-02-02 03:53:41 +00:00
|
|
|
encoded = php_raw_url_encode(name, name_len);
|
2015-06-30 01:05:24 +00:00
|
|
|
smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
|
2015-02-02 03:53:41 +00:00
|
|
|
zend_string_free(encoded);
|
|
|
|
encoded = php_raw_url_encode(value, value_len);
|
2015-06-30 01:05:24 +00:00
|
|
|
smart_str_appendl(&svalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
|
2015-02-02 03:53:41 +00:00
|
|
|
zend_string_free(encoded);
|
2002-05-03 08:32:03 +00:00
|
|
|
} else {
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str_appendl(&sname, name, name_len);
|
|
|
|
smart_str_appendl(&svalue, value, value_len);
|
2002-05-03 08:32:03 +00:00
|
|
|
}
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str_append_smart_str(&BG(url_adapt_state_ex).url_app, &sname);
|
2002-05-04 18:34:29 +00:00
|
|
|
smart_str_appendc(&BG(url_adapt_state_ex).url_app, '=');
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str_append_smart_str(&BG(url_adapt_state_ex).url_app, &svalue);
|
2002-05-04 18:34:29 +00:00
|
|
|
|
2015-01-03 09:22:58 +00:00
|
|
|
smart_str_appends(&BG(url_adapt_state_ex).form_app, "<input type=\"hidden\" name=\"");
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str_append_smart_str(&BG(url_adapt_state_ex).form_app, &sname);
|
2002-05-04 18:34:29 +00:00
|
|
|
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" value=\"");
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str_append_smart_str(&BG(url_adapt_state_ex).form_app, &svalue);
|
2002-05-04 18:34:29 +00:00
|
|
|
smart_str_appends(&BG(url_adapt_state_ex).form_app, "\" />");
|
2002-05-03 08:32:03 +00:00
|
|
|
|
2015-02-02 03:53:41 +00:00
|
|
|
smart_str_free(&sname);
|
|
|
|
smart_str_free(&svalue);
|
2002-05-04 18:34:29 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
2002-05-03 08:32:03 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
PHPAPI int php_url_scanner_reset_vars(void)
|
2002-05-03 08:32:03 +00:00
|
|
|
{
|
2014-03-28 10:46:25 +00:00
|
|
|
if (BG(url_adapt_state_ex).form_app.s) {
|
2015-06-30 01:05:24 +00:00
|
|
|
ZSTR_LEN(BG(url_adapt_state_ex).form_app.s) = 0;
|
2014-03-28 10:46:25 +00:00
|
|
|
}
|
|
|
|
if (BG(url_adapt_state_ex).url_app.s) {
|
2015-06-30 01:05:24 +00:00
|
|
|
ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) = 0;
|
2014-03-28 10:46:25 +00:00
|
|
|
}
|
2002-05-03 08:32:03 +00:00
|
|
|
|
2005-04-03 12:19:23 +00:00
|
|
|
return SUCCESS;
|
2002-05-03 08:32:03 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
PHP_MINIT_FUNCTION(url_scanner)
|
|
|
|
{
|
2002-05-03 08:32:03 +00:00
|
|
|
BG(url_adapt_state_ex).tags = NULL;
|
2001-08-05 16:43:57 +00:00
|
|
|
|
2014-02-18 09:42:46 +00:00
|
|
|
BG(url_adapt_state_ex).form_app.s = BG(url_adapt_state_ex).url_app.s = NULL;
|
2002-05-04 18:34:29 +00:00
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
REGISTER_INI_ENTRIES();
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
PHP_MSHUTDOWN_FUNCTION(url_scanner)
|
|
|
|
{
|
|
|
|
UNREGISTER_INI_ENTRIES();
|
2002-05-03 08:32:03 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
PHP_RINIT_FUNCTION(url_scanner)
|
|
|
|
{
|
|
|
|
BG(url_adapt_state_ex).active = 0;
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2002-05-03 08:32:03 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
PHP_RSHUTDOWN_FUNCTION(url_scanner)
|
|
|
|
{
|
|
|
|
if (BG(url_adapt_state_ex).active) {
|
2014-12-13 22:06:14 +00:00
|
|
|
php_url_scanner_ex_deactivate();
|
2002-05-03 08:32:03 +00:00
|
|
|
BG(url_adapt_state_ex).active = 0;
|
|
|
|
}
|
|
|
|
|
2002-05-05 02:07:33 +00:00
|
|
|
smart_str_free(&BG(url_adapt_state_ex).form_app);
|
|
|
|
smart_str_free(&BG(url_adapt_state_ex).url_app);
|
|
|
|
|
2000-10-16 17:25:36 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|