summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorPeter Kokot <peterkokot@gmail.com>2018-11-10 02:47:26 +0100
committerPeter Kokot <peterkokot@gmail.com>2018-11-11 02:55:46 +0100
commitf0251a8b16631edf06830e08698cef5d76c1e01b (patch)
tree8a2fefe158a2d1cda48fd70bc697ea85e62e9828 /ext
parent1c873c119133c6d5ef13b635cba820236fa5848d (diff)
downloadphp-git-f0251a8b16631edf06830e08698cef5d76c1e01b.tar.gz
Remove lexer files generated by RE2C
This patch removes generated lexer files by re2c during the build process so they are not tracked by Git yet can be still shipped when PHP is released. The genfiles script additionally provides generation of these lexer files when creating a release of the PHP source code. The genfiles script refactorings: - added file header - echoing steps instead of comments - cleaning only lines starting with `#line` - eval removed in favor of direct executed commands - the debug mode `set -x` removed - script can be called from any path - improved comments
Diffstat (limited to 'ext')
-rw-r--r--ext/json/json_scanner.c1661
-rw-r--r--ext/json/php_json_scanner_defs.h8
-rw-r--r--ext/pdo/pdo_sql_parser.c739
-rw-r--r--ext/phar/phar_path_check.c259
-rw-r--r--ext/standard/url_scanner_ex.c1431
-rw-r--r--ext/standard/var_unserializer.c1500
6 files changed, 0 insertions, 5598 deletions
diff --git a/ext/json/json_scanner.c b/ext/json/json_scanner.c
deleted file mode 100644
index 32930fa934..0000000000
--- a/ext/json/json_scanner.c
+++ /dev/null
@@ -1,1661 +0,0 @@
-/* Generated by re2c 1.0.3 */
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | 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. |
- +----------------------------------------------------------------------+
- | Author: Jakub Zelenka <bukka@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-#include "php.h"
-#include "php_json_scanner.h"
-#include "php_json_scanner_defs.h"
-#include "php_json_parser.h"
-#include "json_parser.tab.h"
-
-#define YYCTYPE php_json_ctype
-#define YYCURSOR s->cursor
-#define YYLIMIT s->limit
-#define YYMARKER s->marker
-#define YYCTXMARKER s->ctxmarker
-
-#define YYGETCONDITION() s->state
-#define YYSETCONDITION(yystate) s->state = yystate
-
-#define YYFILL(n)
-
-#define PHP_JSON_CONDITION_SET(condition) YYSETCONDITION(yyc##condition)
-#define PHP_JSON_CONDITION_GOTO(condition) goto yyc_##condition
-#define PHP_JSON_CONDITION_SET_AND_GOTO(condition) \
- PHP_JSON_CONDITION_SET(condition); \
- PHP_JSON_CONDITION_GOTO(condition)
-#define PHP_JSON_CONDITION_GOTO_STR_P2() \
- do { \
- if (s->utf8_invalid) { \
- PHP_JSON_CONDITION_GOTO(STR_P2_BIN); \
- } else { \
- PHP_JSON_CONDITION_GOTO(STR_P2_UTF); \
- } \
- } while(0)
-
-
-#define PHP_JSON_SCANNER_COPY_ESC() php_json_scanner_copy_string(s, 0)
-#define PHP_JSON_SCANNER_COPY_UTF() php_json_scanner_copy_string(s, 5)
-#define PHP_JSON_SCANNER_COPY_UTF_SP() php_json_scanner_copy_string(s, 11)
-
-#define PHP_JSON_INT_MAX_LENGTH (MAX_LENGTH_OF_LONG - 1)
-
-
-static void php_json_scanner_copy_string(php_json_scanner *s, int esc_size)
-{
- size_t len = s->cursor - s->str_start - esc_size - 1;
- if (len) {
- memcpy(s->pstr, s->str_start, len);
- s->pstr += len;
- }
-}
-
-static int php_json_hex_to_int(char code)
-{
- if (code >= '0' && code <= '9') {
- return code - '0';
- } else if (code >= 'A' && code <= 'F') {
- return code - ('A' - 10);
- } else if (code >= 'a' && code <= 'f') {
- return code - ('a' - 10);
- } else {
- /* this should never happened (just to suppress compiler warning) */
- return -1;
- }
-}
-
-static int php_json_ucs2_to_int_ex(php_json_scanner *s, int size, int start)
-{
- int i, code = 0;
- php_json_ctype *pc = s->cursor - start;
- for (i = 0; i < size; i++) {
- code |= php_json_hex_to_int(*(pc--)) << (i * 4);
- }
- return code;
-}
-
-static int php_json_ucs2_to_int(php_json_scanner *s, int size)
-{
- return php_json_ucs2_to_int_ex(s, size, 1);
-}
-
-void php_json_scanner_init(php_json_scanner *s, char *str, size_t str_len, int options)
-{
- s->cursor = (php_json_ctype *) str;
- s->limit = (php_json_ctype *) str + str_len;
- s->options = options;
- PHP_JSON_CONDITION_SET(JS);
-}
-
-int php_json_scan(php_json_scanner *s)
-{
- ZVAL_NULL(&s->value);
-
-std:
- s->token = s->cursor;
-
-
- {
- YYCTYPE yych;
- unsigned int yyaccept = 0;
- if (YYGETCONDITION() < 2) {
- if (YYGETCONDITION() < 1) {
- goto yyc_JS;
- } else {
- goto yyc_STR_P1;
- }
- } else {
- if (YYGETCONDITION() < 3) {
- goto yyc_STR_P2_BIN;
- } else {
- goto yyc_STR_P2_UTF;
- }
- }
-/* *********************************** */
-yyc_JS:
- {
- static const unsigned char yybm[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 64, 0, 0, 0, 64, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 64, 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, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- };
- yych = *YYCURSOR;
- if (yych <= ']') {
- if (yych <= '"') {
- if (yych <= '\f') {
- if (yych <= 0x08) {
- if (yych >= 0x01) goto yy5;
- } else {
- if (yych <= '\t') goto yy7;
- if (yych <= '\n') goto yy10;
- goto yy5;
- }
- } else {
- if (yych <= 0x1F) {
- if (yych <= '\r') goto yy11;
- goto yy5;
- } else {
- if (yych <= ' ') goto yy7;
- if (yych <= '!') goto yy12;
- goto yy14;
- }
- }
- } else {
- if (yych <= '0') {
- if (yych <= ',') {
- if (yych <= '+') goto yy12;
- goto yy16;
- } else {
- if (yych <= '-') goto yy18;
- if (yych <= '/') goto yy12;
- goto yy19;
- }
- } else {
- if (yych <= 'Z') {
- if (yych <= '9') goto yy21;
- if (yych <= ':') goto yy23;
- goto yy12;
- } else {
- if (yych <= '[') goto yy25;
- if (yych <= '\\') goto yy12;
- goto yy27;
- }
- }
- }
- } else {
- if (yych <= '}') {
- if (yych <= 's') {
- if (yych <= 'f') {
- if (yych <= 'e') goto yy12;
- goto yy29;
- } else {
- if (yych == 'n') goto yy30;
- goto yy12;
- }
- } else {
- if (yych <= 'z') {
- if (yych <= 't') goto yy31;
- goto yy12;
- } else {
- if (yych <= '{') goto yy32;
- if (yych <= '|') goto yy12;
- goto yy34;
- }
- }
- } else {
- if (yych <= 0xEC) {
- if (yych <= 0xC1) {
- if (yych <= 0x7F) goto yy12;
- goto yy36;
- } else {
- if (yych <= 0xDF) goto yy38;
- if (yych <= 0xE0) goto yy39;
- goto yy40;
- }
- } else {
- if (yych <= 0xF0) {
- if (yych <= 0xED) goto yy41;
- if (yych <= 0xEF) goto yy40;
- goto yy42;
- } else {
- if (yych <= 0xF3) goto yy43;
- if (yych <= 0xF4) goto yy44;
- goto yy36;
- }
- }
- }
- }
- ++YYCURSOR;
- {
- if (s->limit < s->cursor) {
- return PHP_JSON_T_EOI;
- } else {
- s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
- return PHP_JSON_T_ERROR;
- }
- }
-yy5:
- ++YYCURSOR;
- {
- s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
- return PHP_JSON_T_ERROR;
- }
-yy7:
- yych = *++YYCURSOR;
-yy8:
- if (yybm[0+yych] & 64) {
- goto yy7;
- }
-yy9:
- { goto std; }
-yy10:
- ++YYCURSOR;
- goto yy9;
-yy11:
- yych = *++YYCURSOR;
- if (yych == '\n') goto yy10;
- goto yy8;
-yy12:
- ++YYCURSOR;
-yy13:
- {
- s->errcode = PHP_JSON_ERROR_SYNTAX;
- return PHP_JSON_T_ERROR;
- }
-yy14:
- ++YYCURSOR;
- {
- s->str_start = s->cursor;
- s->str_esc = 0;
- s->utf8_invalid = 0;
- s->utf8_invalid_count = 0;
- PHP_JSON_CONDITION_SET_AND_GOTO(STR_P1);
- }
-yy16:
- ++YYCURSOR;
- { return ','; }
-yy18:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy13;
- if (yych <= '0') goto yy19;
- if (yych <= '9') goto yy21;
- goto yy13;
-yy19:
- yyaccept = 0;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 'D') {
- if (yych == '.') goto yy45;
- } else {
- if (yych <= 'E') goto yy47;
- if (yych == 'e') goto yy47;
- }
-yy20:
- {
- zend_bool bigint = 0, negative = s->token[0] == '-';
- size_t digits = (size_t) (s->cursor - s->token - negative);
- if (digits >= PHP_JSON_INT_MAX_LENGTH) {
- if (digits == PHP_JSON_INT_MAX_LENGTH) {
- int cmp = strncmp((char *) (s->token + negative), LONG_MIN_DIGITS, PHP_JSON_INT_MAX_LENGTH);
- if (!(cmp < 0 || (cmp == 0 && negative))) {
- bigint = 1;
- }
- } else {
- bigint = 1;
- }
- }
- if (!bigint) {
- ZVAL_LONG(&s->value, ZEND_STRTOL((char *) s->token, NULL, 10));
- return PHP_JSON_T_INT;
- } else if (s->options & PHP_JSON_BIGINT_AS_STRING) {
- ZVAL_STRINGL(&s->value, (char *) s->token, s->cursor - s->token);
- return PHP_JSON_T_STRING;
- } else {
- ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
- return PHP_JSON_T_DOUBLE;
- }
- }
-yy21:
- yyaccept = 0;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yybm[0+yych] & 128) {
- goto yy21;
- }
- if (yych <= 'D') {
- if (yych == '.') goto yy45;
- goto yy20;
- } else {
- if (yych <= 'E') goto yy47;
- if (yych == 'e') goto yy47;
- goto yy20;
- }
-yy23:
- ++YYCURSOR;
- { return ':'; }
-yy25:
- ++YYCURSOR;
- { return '['; }
-yy27:
- ++YYCURSOR;
- { return ']'; }
-yy29:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == 'a') goto yy48;
- goto yy13;
-yy30:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == 'u') goto yy49;
- goto yy13;
-yy31:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == 'r') goto yy50;
- goto yy13;
-yy32:
- ++YYCURSOR;
- { return '{'; }
-yy34:
- ++YYCURSOR;
- { return '}'; }
-yy36:
- ++YYCURSOR;
-yy37:
- {
- s->errcode = PHP_JSON_ERROR_UTF8;
- return PHP_JSON_T_ERROR;
- }
-yy38:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy37;
- if (yych <= 0xBF) goto yy12;
- goto yy37;
-yy39:
- yyaccept = 2;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x9F) goto yy37;
- if (yych <= 0xBF) goto yy51;
- goto yy37;
-yy40:
- yyaccept = 2;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy37;
- if (yych <= 0xBF) goto yy51;
- goto yy37;
-yy41:
- yyaccept = 2;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy37;
- if (yych <= 0x9F) goto yy51;
- goto yy37;
-yy42:
- yyaccept = 2;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x8F) goto yy37;
- if (yych <= 0xBF) goto yy52;
- goto yy37;
-yy43:
- yyaccept = 2;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy37;
- if (yych <= 0xBF) goto yy52;
- goto yy37;
-yy44:
- yyaccept = 2;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy37;
- if (yych <= 0x8F) goto yy52;
- goto yy37;
-yy45:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy46;
- if (yych <= '9') goto yy53;
-yy46:
- YYCURSOR = YYMARKER;
- if (yyaccept <= 1) {
- if (yyaccept == 0) {
- goto yy20;
- } else {
- goto yy13;
- }
- } else {
- if (yyaccept == 2) {
- goto yy37;
- } else {
- goto yy55;
- }
- }
-yy47:
- yych = *++YYCURSOR;
- if (yych <= ',') {
- if (yych == '+') goto yy56;
- goto yy46;
- } else {
- if (yych <= '-') goto yy56;
- if (yych <= '/') goto yy46;
- if (yych <= '9') goto yy57;
- goto yy46;
- }
-yy48:
- yych = *++YYCURSOR;
- if (yych == 'l') goto yy59;
- goto yy46;
-yy49:
- yych = *++YYCURSOR;
- if (yych == 'l') goto yy60;
- goto yy46;
-yy50:
- yych = *++YYCURSOR;
- if (yych == 'u') goto yy61;
- goto yy46;
-yy51:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy46;
- if (yych <= 0xBF) goto yy12;
- goto yy46;
-yy52:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy46;
- if (yych <= 0xBF) goto yy51;
- goto yy46;
-yy53:
- yyaccept = 3;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 'D') {
- if (yych <= '/') goto yy55;
- if (yych <= '9') goto yy53;
- } else {
- if (yych <= 'E') goto yy47;
- if (yych == 'e') goto yy47;
- }
-yy55:
- {
- ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
- return PHP_JSON_T_DOUBLE;
- }
-yy56:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy46;
- if (yych >= ':') goto yy46;
-yy57:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy55;
- if (yych <= '9') goto yy57;
- goto yy55;
-yy59:
- yych = *++YYCURSOR;
- if (yych == 's') goto yy62;
- goto yy46;
-yy60:
- yych = *++YYCURSOR;
- if (yych == 'l') goto yy63;
- goto yy46;
-yy61:
- yych = *++YYCURSOR;
- if (yych == 'e') goto yy65;
- goto yy46;
-yy62:
- yych = *++YYCURSOR;
- if (yych == 'e') goto yy67;
- goto yy46;
-yy63:
- ++YYCURSOR;
- {
- ZVAL_NULL(&s->value);
- return PHP_JSON_T_NUL;
- }
-yy65:
- ++YYCURSOR;
- {
- ZVAL_TRUE(&s->value);
- return PHP_JSON_T_TRUE;
- }
-yy67:
- ++YYCURSOR;
- {
- ZVAL_FALSE(&s->value);
- return PHP_JSON_T_FALSE;
- }
- }
-/* *********************************** */
-yyc_STR_P1:
- yych = *YYCURSOR;
- if (yych <= 0xDF) {
- if (yych <= '[') {
- if (yych <= 0x1F) goto yy71;
- if (yych == '"') goto yy75;
- goto yy73;
- } else {
- if (yych <= '\\') goto yy77;
- if (yych <= 0x7F) goto yy73;
- if (yych <= 0xC1) goto yy79;
- goto yy81;
- }
- } else {
- if (yych <= 0xEF) {
- if (yych <= 0xE0) goto yy82;
- if (yych == 0xED) goto yy84;
- goto yy83;
- } else {
- if (yych <= 0xF0) goto yy85;
- if (yych <= 0xF3) goto yy86;
- if (yych <= 0xF4) goto yy87;
- goto yy79;
- }
- }
-yy71:
- ++YYCURSOR;
- {
- s->errcode = PHP_JSON_ERROR_CTRL_CHAR;
- return PHP_JSON_T_ERROR;
- }
-yy73:
- ++YYCURSOR;
- { PHP_JSON_CONDITION_GOTO(STR_P1); }
-yy75:
- ++YYCURSOR;
- {
- zend_string *str;
- size_t len = s->cursor - s->str_start - s->str_esc - 1 + s->utf8_invalid_count;
- if (len == 0) {
- PHP_JSON_CONDITION_SET(JS);
- ZVAL_EMPTY_STRING(&s->value);
- return PHP_JSON_T_ESTRING;
- }
- str = zend_string_alloc(len, 0);
- ZSTR_VAL(str)[len] = '\0';
- ZVAL_STR(&s->value, str);
- if (s->str_esc || s->utf8_invalid) {
- s->pstr = (php_json_ctype *) Z_STRVAL(s->value);
- s->cursor = s->str_start;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- } else {
- memcpy(Z_STRVAL(s->value), s->str_start, len);
- PHP_JSON_CONDITION_SET(JS);
- return PHP_JSON_T_STRING;
- }
- }
-yy77:
- yyaccept = 0;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 'e') {
- if (yych <= '/') {
- if (yych == '"') goto yy88;
- if (yych >= '/') goto yy88;
- } else {
- if (yych <= '\\') {
- if (yych >= '\\') goto yy88;
- } else {
- if (yych == 'b') goto yy88;
- }
- }
- } else {
- if (yych <= 'q') {
- if (yych <= 'f') goto yy88;
- if (yych == 'n') goto yy88;
- } else {
- if (yych <= 's') {
- if (yych <= 'r') goto yy88;
- } else {
- if (yych <= 't') goto yy88;
- if (yych <= 'u') goto yy90;
- }
- }
- }
-yy78:
- {
- s->errcode = PHP_JSON_ERROR_SYNTAX;
- return PHP_JSON_T_ERROR;
- }
-yy79:
- ++YYCURSOR;
-yy80:
- {
- if (s->options & (PHP_JSON_INVALID_UTF8_IGNORE | PHP_JSON_INVALID_UTF8_SUBSTITUTE)) {
- if (s->options & PHP_JSON_INVALID_UTF8_SUBSTITUTE) {
- if (s->utf8_invalid_count > INT_MAX - 2) {
- s->errcode = PHP_JSON_ERROR_UTF8;
- return PHP_JSON_T_ERROR;
- }
- s->utf8_invalid_count += 2;
- } else {
- s->utf8_invalid_count--;
- }
- s->utf8_invalid = 1;
- PHP_JSON_CONDITION_GOTO(STR_P1);
- }
- s->errcode = PHP_JSON_ERROR_UTF8;
- return PHP_JSON_T_ERROR;
- }
-yy81:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy80;
- if (yych <= 0xBF) goto yy73;
- goto yy80;
-yy82:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x9F) goto yy80;
- if (yych <= 0xBF) goto yy92;
- goto yy80;
-yy83:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy80;
- if (yych <= 0xBF) goto yy92;
- goto yy80;
-yy84:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy80;
- if (yych <= 0x9F) goto yy92;
- goto yy80;
-yy85:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x8F) goto yy80;
- if (yych <= 0xBF) goto yy93;
- goto yy80;
-yy86:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy80;
- if (yych <= 0xBF) goto yy93;
- goto yy80;
-yy87:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy80;
- if (yych <= 0x8F) goto yy93;
- goto yy80;
-yy88:
- ++YYCURSOR;
- {
- s->str_esc++;
- PHP_JSON_CONDITION_GOTO(STR_P1);
- }
-yy90:
- yych = *++YYCURSOR;
- if (yych <= 'D') {
- if (yych <= '9') {
- if (yych <= '/') goto yy91;
- if (yych <= '0') goto yy94;
- goto yy95;
- } else {
- if (yych <= '@') goto yy91;
- if (yych <= 'C') goto yy95;
- goto yy96;
- }
- } else {
- if (yych <= 'c') {
- if (yych <= 'F') goto yy95;
- if (yych >= 'a') goto yy95;
- } else {
- if (yych <= 'd') goto yy96;
- if (yych <= 'f') goto yy95;
- }
- }
-yy91:
- YYCURSOR = YYMARKER;
- if (yyaccept <= 1) {
- if (yyaccept == 0) {
- goto yy78;
- } else {
- goto yy80;
- }
- } else {
- goto yy114;
- }
-yy92:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy91;
- if (yych <= 0xBF) goto yy73;
- goto yy91;
-yy93:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy91;
- if (yych <= 0xBF) goto yy92;
- goto yy91;
-yy94:
- yych = *++YYCURSOR;
- if (yych <= '9') {
- if (yych <= '/') goto yy91;
- if (yych <= '0') goto yy97;
- if (yych <= '7') goto yy98;
- goto yy99;
- } else {
- if (yych <= 'F') {
- if (yych <= '@') goto yy91;
- goto yy99;
- } else {
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy99;
- goto yy91;
- }
- }
-yy95:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy99;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy99;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy99;
- goto yy91;
- }
-yy96:
- yych = *++YYCURSOR;
- if (yych <= 'B') {
- if (yych <= '7') {
- if (yych <= '/') goto yy91;
- goto yy99;
- } else {
- if (yych <= '9') goto yy100;
- if (yych <= '@') goto yy91;
- goto yy100;
- }
- } else {
- if (yych <= '`') {
- if (yych <= 'F') goto yy101;
- goto yy91;
- } else {
- if (yych <= 'b') goto yy100;
- if (yych <= 'f') goto yy101;
- goto yy91;
- }
- }
-yy97:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '7') goto yy102;
- if (yych <= '9') goto yy103;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy103;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy103;
- goto yy91;
- }
-yy98:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy103;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy103;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy103;
- goto yy91;
- }
-yy99:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy104;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy104;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy104;
- goto yy91;
- }
-yy100:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy105;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy105;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy105;
- goto yy91;
- }
-yy101:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy106;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy106;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy106;
- goto yy91;
- }
-yy102:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy107;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy107;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy107;
- goto yy91;
- }
-yy103:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy109;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy109;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy109;
- goto yy91;
- }
-yy104:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy111;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy111;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy111;
- goto yy91;
- }
-yy105:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy113;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy113;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy113;
- goto yy91;
- }
-yy106:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych <= '9') goto yy115;
- goto yy91;
- } else {
- if (yych <= 'F') goto yy115;
- if (yych <= '`') goto yy91;
- if (yych <= 'f') goto yy115;
- goto yy91;
- }
-yy107:
- ++YYCURSOR;
- {
- s->str_esc += 5;
- PHP_JSON_CONDITION_GOTO(STR_P1);
- }
-yy109:
- ++YYCURSOR;
- {
- s->str_esc += 4;
- PHP_JSON_CONDITION_GOTO(STR_P1);
- }
-yy111:
- ++YYCURSOR;
- {
- s->str_esc += 3;
- PHP_JSON_CONDITION_GOTO(STR_P1);
- }
-yy113:
- yyaccept = 2;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == '\\') goto yy116;
-yy114:
- {
- s->errcode = PHP_JSON_ERROR_UTF16;
- return PHP_JSON_T_ERROR;
- }
-yy115:
- ++YYCURSOR;
- goto yy114;
-yy116:
- yych = *++YYCURSOR;
- if (yych != 'u') goto yy91;
- yych = *++YYCURSOR;
- if (yych == 'D') goto yy118;
- if (yych != 'd') goto yy91;
-yy118:
- yych = *++YYCURSOR;
- if (yych <= 'B') goto yy91;
- if (yych <= 'F') goto yy119;
- if (yych <= 'b') goto yy91;
- if (yych >= 'g') goto yy91;
-yy119:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych >= ':') goto yy91;
- } else {
- if (yych <= 'F') goto yy120;
- if (yych <= '`') goto yy91;
- if (yych >= 'g') goto yy91;
- }
-yy120:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy91;
- if (yych >= ':') goto yy91;
- } else {
- if (yych <= 'F') goto yy121;
- if (yych <= '`') goto yy91;
- if (yych >= 'g') goto yy91;
- }
-yy121:
- ++YYCURSOR;
- {
- s->str_esc += 8;
- PHP_JSON_CONDITION_GOTO(STR_P1);
- }
-/* *********************************** */
-yyc_STR_P2_BIN:
- yych = *YYCURSOR;
- if (yych <= 0xDF) {
- if (yych <= '[') {
- if (yych == '"') goto yy127;
- } else {
- if (yych <= '\\') goto yy129;
- if (yych <= 0x7F) goto yy125;
- if (yych <= 0xC1) goto yy131;
- goto yy133;
- }
- } else {
- if (yych <= 0xEF) {
- if (yych <= 0xE0) goto yy134;
- if (yych == 0xED) goto yy136;
- goto yy135;
- } else {
- if (yych <= 0xF0) goto yy137;
- if (yych <= 0xF3) goto yy138;
- if (yych <= 0xF4) goto yy139;
- goto yy131;
- }
- }
-yy125:
- ++YYCURSOR;
- { PHP_JSON_CONDITION_GOTO(STR_P2_BIN); }
-yy127:
- ++YYCURSOR;
- YYSETCONDITION(yycJS);
- {
- PHP_JSON_SCANNER_COPY_ESC();
- return PHP_JSON_T_STRING;
- }
-yy129:
- yyaccept = 0;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == 'u') goto yy140;
-yy130:
- {
- char esc;
- PHP_JSON_SCANNER_COPY_ESC();
- switch (*s->cursor) {
- case 'b':
- esc = '\b';
- break;
- case 'f':
- esc = '\f'; break;
- case 'n':
- esc = '\n';
- break;
- case 'r':
- esc = '\r';
- break;
- case 't':
- esc = '\t';
- break;
- case '\\':
- case '/':
- case '"':
- esc = *s->cursor;
- break;
- default:
- s->errcode = PHP_JSON_ERROR_SYNTAX;
- return PHP_JSON_T_ERROR;
- }
- *(s->pstr++) = esc;
- ++YYCURSOR;
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy131:
- ++YYCURSOR;
-yy132:
- {
- if (s->utf8_invalid) {
- PHP_JSON_SCANNER_COPY_ESC();
- if (s->options & PHP_JSON_INVALID_UTF8_SUBSTITUTE) {
- *(s->pstr++) = (char) (0xe0 | (0xfffd >> 12));
- *(s->pstr++) = (char) (0x80 | ((0xfffd >> 6) & 0x3f));
- *(s->pstr++) = (char) (0x80 | (0xfffd & 0x3f));
- }
- s->str_start = s->cursor;
- }
- PHP_JSON_CONDITION_GOTO(STR_P2_BIN);
- }
-yy133:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy132;
- if (yych <= 0xBF) goto yy125;
- goto yy132;
-yy134:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x9F) goto yy132;
- if (yych <= 0xBF) goto yy142;
- goto yy132;
-yy135:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy132;
- if (yych <= 0xBF) goto yy142;
- goto yy132;
-yy136:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy132;
- if (yych <= 0x9F) goto yy142;
- goto yy132;
-yy137:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x8F) goto yy132;
- if (yych <= 0xBF) goto yy143;
- goto yy132;
-yy138:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy132;
- if (yych <= 0xBF) goto yy143;
- goto yy132;
-yy139:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy132;
- if (yych <= 0x8F) goto yy143;
- goto yy132;
-yy140:
- yych = *++YYCURSOR;
- if (yych <= 'D') {
- if (yych <= '9') {
- if (yych <= '/') goto yy141;
- if (yych <= '0') goto yy144;
- goto yy145;
- } else {
- if (yych <= '@') goto yy141;
- if (yych <= 'C') goto yy145;
- goto yy146;
- }
- } else {
- if (yych <= 'c') {
- if (yych <= 'F') goto yy145;
- if (yych >= 'a') goto yy145;
- } else {
- if (yych <= 'd') goto yy146;
- if (yych <= 'f') goto yy145;
- }
- }
-yy141:
- YYCURSOR = YYMARKER;
- if (yyaccept == 0) {
- goto yy130;
- } else {
- goto yy132;
- }
-yy142:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy141;
- if (yych <= 0xBF) goto yy125;
- goto yy141;
-yy143:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy141;
- if (yych <= 0xBF) goto yy142;
- goto yy141;
-yy144:
- yych = *++YYCURSOR;
- if (yych <= '9') {
- if (yych <= '/') goto yy141;
- if (yych <= '0') goto yy147;
- if (yych <= '7') goto yy148;
- goto yy149;
- } else {
- if (yych <= 'F') {
- if (yych <= '@') goto yy141;
- goto yy149;
- } else {
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy149;
- goto yy141;
- }
- }
-yy145:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy149;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy149;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy149;
- goto yy141;
- }
-yy146:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '7') goto yy149;
- if (yych <= '9') goto yy150;
- goto yy141;
- } else {
- if (yych <= 'B') goto yy150;
- if (yych <= '`') goto yy141;
- if (yych <= 'b') goto yy150;
- goto yy141;
- }
-yy147:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '7') goto yy151;
- if (yych <= '9') goto yy152;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy152;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy152;
- goto yy141;
- }
-yy148:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy152;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy152;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy152;
- goto yy141;
- }
-yy149:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy153;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy153;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy153;
- goto yy141;
- }
-yy150:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy154;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy154;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy154;
- goto yy141;
- }
-yy151:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy155;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy155;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy155;
- goto yy141;
- }
-yy152:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy157;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy157;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy157;
- goto yy141;
- }
-yy153:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy159;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy159;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy159;
- goto yy141;
- }
-yy154:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych <= '9') goto yy161;
- goto yy141;
- } else {
- if (yych <= 'F') goto yy161;
- if (yych <= '`') goto yy141;
- if (yych <= 'f') goto yy161;
- goto yy141;
- }
-yy155:
- ++YYCURSOR;
- {
- int utf16 = php_json_ucs2_to_int(s, 2);
- PHP_JSON_SCANNER_COPY_UTF();
- *(s->pstr++) = (char) utf16;
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy157:
- ++YYCURSOR;
- {
- int utf16 = php_json_ucs2_to_int(s, 3);
- PHP_JSON_SCANNER_COPY_UTF();
- *(s->pstr++) = (char) (0xc0 | (utf16 >> 6));
- *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy159:
- ++YYCURSOR;
- {
- int utf16 = php_json_ucs2_to_int(s, 4);
- PHP_JSON_SCANNER_COPY_UTF();
- *(s->pstr++) = (char) (0xe0 | (utf16 >> 12));
- *(s->pstr++) = (char) (0x80 | ((utf16 >> 6) & 0x3f));
- *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy161:
- yych = *++YYCURSOR;
- if (yych != '\\') goto yy141;
- yych = *++YYCURSOR;
- if (yych != 'u') goto yy141;
- yych = *++YYCURSOR;
- if (yych == 'D') goto yy164;
- if (yych != 'd') goto yy141;
-yy164:
- yych = *++YYCURSOR;
- if (yych <= 'B') goto yy141;
- if (yych <= 'F') goto yy165;
- if (yych <= 'b') goto yy141;
- if (yych >= 'g') goto yy141;
-yy165:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych >= ':') goto yy141;
- } else {
- if (yych <= 'F') goto yy166;
- if (yych <= '`') goto yy141;
- if (yych >= 'g') goto yy141;
- }
-yy166:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy141;
- if (yych >= ':') goto yy141;
- } else {
- if (yych <= 'F') goto yy167;
- if (yych <= '`') goto yy141;
- if (yych >= 'g') goto yy141;
- }
-yy167:
- ++YYCURSOR;
- {
- int utf32, utf16_hi, utf16_lo;
- utf16_hi = php_json_ucs2_to_int(s, 4);
- utf16_lo = php_json_ucs2_to_int_ex(s, 4, 7);
- utf32 = ((utf16_lo & 0x3FF) << 10) + (utf16_hi & 0x3FF) + 0x10000;
- PHP_JSON_SCANNER_COPY_UTF_SP();
- *(s->pstr++) = (char) (0xf0 | (utf32 >> 18));
- *(s->pstr++) = (char) (0x80 | ((utf32 >> 12) & 0x3f));
- *(s->pstr++) = (char) (0x80 | ((utf32 >> 6) & 0x3f));
- *(s->pstr++) = (char) (0x80 | (utf32 & 0x3f));
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-/* *********************************** */
-yyc_STR_P2_UTF:
- yych = *YYCURSOR;
- if (yych == '"') goto yy173;
- if (yych == '\\') goto yy175;
- ++YYCURSOR;
- { PHP_JSON_CONDITION_GOTO(STR_P2_UTF); }
-yy173:
- ++YYCURSOR;
- YYSETCONDITION(yycJS);
- {
- PHP_JSON_SCANNER_COPY_ESC();
- return PHP_JSON_T_STRING;
- }
-yy175:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == 'u') goto yy177;
-yy176:
- {
- char esc;
- PHP_JSON_SCANNER_COPY_ESC();
- switch (*s->cursor) {
- case 'b':
- esc = '\b';
- break;
- case 'f':
- esc = '\f'; break;
- case 'n':
- esc = '\n';
- break;
- case 'r':
- esc = '\r';
- break;
- case 't':
- esc = '\t';
- break;
- case '\\':
- case '/':
- case '"':
- esc = *s->cursor;
- break;
- default:
- s->errcode = PHP_JSON_ERROR_SYNTAX;
- return PHP_JSON_T_ERROR;
- }
- *(s->pstr++) = esc;
- ++YYCURSOR;
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy177:
- yych = *++YYCURSOR;
- if (yych <= 'D') {
- if (yych <= '9') {
- if (yych <= '/') goto yy178;
- if (yych <= '0') goto yy179;
- goto yy180;
- } else {
- if (yych <= '@') goto yy178;
- if (yych <= 'C') goto yy180;
- goto yy181;
- }
- } else {
- if (yych <= 'c') {
- if (yych <= 'F') goto yy180;
- if (yych >= 'a') goto yy180;
- } else {
- if (yych <= 'd') goto yy181;
- if (yych <= 'f') goto yy180;
- }
- }
-yy178:
- YYCURSOR = YYMARKER;
- goto yy176;
-yy179:
- yych = *++YYCURSOR;
- if (yych <= '9') {
- if (yych <= '/') goto yy178;
- if (yych <= '0') goto yy182;
- if (yych <= '7') goto yy183;
- goto yy184;
- } else {
- if (yych <= 'F') {
- if (yych <= '@') goto yy178;
- goto yy184;
- } else {
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy184;
- goto yy178;
- }
- }
-yy180:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy184;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy184;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy184;
- goto yy178;
- }
-yy181:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '7') goto yy184;
- if (yych <= '9') goto yy185;
- goto yy178;
- } else {
- if (yych <= 'B') goto yy185;
- if (yych <= '`') goto yy178;
- if (yych <= 'b') goto yy185;
- goto yy178;
- }
-yy182:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '7') goto yy186;
- if (yych <= '9') goto yy187;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy187;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy187;
- goto yy178;
- }
-yy183:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy187;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy187;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy187;
- goto yy178;
- }
-yy184:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy188;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy188;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy188;
- goto yy178;
- }
-yy185:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy189;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy189;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy189;
- goto yy178;
- }
-yy186:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy190;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy190;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy190;
- goto yy178;
- }
-yy187:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy192;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy192;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy192;
- goto yy178;
- }
-yy188:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy194;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy194;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy194;
- goto yy178;
- }
-yy189:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych <= '9') goto yy196;
- goto yy178;
- } else {
- if (yych <= 'F') goto yy196;
- if (yych <= '`') goto yy178;
- if (yych <= 'f') goto yy196;
- goto yy178;
- }
-yy190:
- ++YYCURSOR;
- {
- int utf16 = php_json_ucs2_to_int(s, 2);
- PHP_JSON_SCANNER_COPY_UTF();
- *(s->pstr++) = (char) utf16;
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy192:
- ++YYCURSOR;
- {
- int utf16 = php_json_ucs2_to_int(s, 3);
- PHP_JSON_SCANNER_COPY_UTF();
- *(s->pstr++) = (char) (0xc0 | (utf16 >> 6));
- *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy194:
- ++YYCURSOR;
- {
- int utf16 = php_json_ucs2_to_int(s, 4);
- PHP_JSON_SCANNER_COPY_UTF();
- *(s->pstr++) = (char) (0xe0 | (utf16 >> 12));
- *(s->pstr++) = (char) (0x80 | ((utf16 >> 6) & 0x3f));
- *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
-yy196:
- yych = *++YYCURSOR;
- if (yych != '\\') goto yy178;
- yych = *++YYCURSOR;
- if (yych != 'u') goto yy178;
- yych = *++YYCURSOR;
- if (yych == 'D') goto yy199;
- if (yych != 'd') goto yy178;
-yy199:
- yych = *++YYCURSOR;
- if (yych <= 'B') goto yy178;
- if (yych <= 'F') goto yy200;
- if (yych <= 'b') goto yy178;
- if (yych >= 'g') goto yy178;
-yy200:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych >= ':') goto yy178;
- } else {
- if (yych <= 'F') goto yy201;
- if (yych <= '`') goto yy178;
- if (yych >= 'g') goto yy178;
- }
-yy201:
- yych = *++YYCURSOR;
- if (yych <= '@') {
- if (yych <= '/') goto yy178;
- if (yych >= ':') goto yy178;
- } else {
- if (yych <= 'F') goto yy202;
- if (yych <= '`') goto yy178;
- if (yych >= 'g') goto yy178;
- }
-yy202:
- ++YYCURSOR;
- {
- int utf32, utf16_hi, utf16_lo;
- utf16_hi = php_json_ucs2_to_int(s, 4);
- utf16_lo = php_json_ucs2_to_int_ex(s, 4, 7);
- utf32 = ((utf16_lo & 0x3FF) << 10) + (utf16_hi & 0x3FF) + 0x10000;
- PHP_JSON_SCANNER_COPY_UTF_SP();
- *(s->pstr++) = (char) (0xf0 | (utf32 >> 18));
- *(s->pstr++) = (char) (0x80 | ((utf32 >> 12) & 0x3f));
- *(s->pstr++) = (char) (0x80 | ((utf32 >> 6) & 0x3f));
- *(s->pstr++) = (char) (0x80 | (utf32 & 0x3f));
- s->str_start = s->cursor;
- PHP_JSON_CONDITION_GOTO_STR_P2();
- }
- }
-
-
-}
-
diff --git a/ext/json/php_json_scanner_defs.h b/ext/json/php_json_scanner_defs.h
deleted file mode 100644
index 97ad7626ad..0000000000
--- a/ext/json/php_json_scanner_defs.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Generated by re2c 1.0.3 */
-
-enum YYCONDTYPE {
- yycJS,
- yycSTR_P1,
- yycSTR_P2_BIN,
- yycSTR_P2_UTF,
-};
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
deleted file mode 100644
index 779a70280a..0000000000
--- a/ext/pdo/pdo_sql_parser.c
+++ /dev/null
@@ -1,739 +0,0 @@
-/* Generated by re2c 1.0.3 */
-#line 1 "ext/pdo/pdo_sql_parser.re"
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | 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. |
- +----------------------------------------------------------------------+
- | Author: George Schlossnagle <george@omniti.com> |
- +----------------------------------------------------------------------+
-*/
-
-#include "php.h"
-#include "php_pdo_driver.h"
-#include "php_pdo_int.h"
-
-#define PDO_PARSER_TEXT 1
-#define PDO_PARSER_BIND 2
-#define PDO_PARSER_BIND_POS 3
-#define PDO_PARSER_EOI 4
-
-#define RET(i) {s->cur = cursor; return i; }
-#define SKIP_ONE(i) {s->cur = s->tok + 1; return i; }
-
-#define YYCTYPE unsigned char
-#define YYCURSOR cursor
-#define YYLIMIT s->end
-#define YYMARKER s->ptr
-#define YYFILL(n) { RET(PDO_PARSER_EOI); }
-
-typedef struct Scanner {
- char *ptr, *cur, *tok, *end;
-} Scanner;
-
-static int scan(Scanner *s)
-{
- char *cursor = s->cur;
-
- s->tok = cursor;
- #line 53 "ext/pdo/pdo_sql_parser.re"
-
-
-
-#line 53 "ext/pdo/pdo_sql_parser.c"
-{
- YYCTYPE yych;
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- switch (yych) {
- case 0x00: goto yy2;
- case '"': goto yy6;
- case '\'': goto yy8;
- case '(':
- case ')':
- case '*':
- case '+':
- case ',':
- case '.': goto yy9;
- case '-': goto yy10;
- case '/': goto yy11;
- case ':': goto yy12;
- case '?': goto yy13;
- default: goto yy3;
- }
-yy2:
- YYCURSOR = YYMARKER;
- goto yy7;
-yy3:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- switch (yych) {
- case 0x00:
- case '"':
- case '\'':
- case '(':
- case ')':
- case '*':
- case '+':
- case ',':
- case '-':
- case '.':
- case '/':
- case ':':
- case '?': goto yy5;
- default: goto yy3;
- }
-yy5:
-#line 63 "ext/pdo/pdo_sql_parser.re"
- { RET(PDO_PARSER_TEXT); }
-#line 100 "ext/pdo/pdo_sql_parser.c"
-yy6:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych >= 0x01) goto yy16;
-yy7:
-#line 61 "ext/pdo/pdo_sql_parser.re"
- { SKIP_ONE(PDO_PARSER_TEXT); }
-#line 107 "ext/pdo/pdo_sql_parser.c"
-yy8:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x00) goto yy7;
- goto yy21;
-yy9:
- ++YYCURSOR;
- goto yy7;
-yy10:
- yych = *++YYCURSOR;
- switch (yych) {
- case '-': goto yy25;
- default: goto yy7;
- }
-yy11:
- yych = *++YYCURSOR;
- switch (yych) {
- case '*': goto yy28;
- default: goto yy7;
- }
-yy12:
- yych = *++YYCURSOR;
- switch (yych) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- case 'G':
- case 'H':
- case 'I':
- case 'J':
- case 'K':
- case 'L':
- case 'M':
- case 'N':
- case 'O':
- case 'P':
- case 'Q':
- case 'R':
- case 'S':
- case 'T':
- case 'U':
- case 'V':
- case 'W':
- case 'X':
- case 'Y':
- case 'Z':
- case '_':
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z': goto yy30;
- case ':': goto yy33;
- default: goto yy7;
- }
-yy13:
- yych = *++YYCURSOR;
- switch (yych) {
- case '?': goto yy36;
- default: goto yy14;
- }
-yy14:
-#line 60 "ext/pdo/pdo_sql_parser.re"
- { RET(PDO_PARSER_BIND_POS); }
-#line 205 "ext/pdo/pdo_sql_parser.c"
-yy15:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy16:
- switch (yych) {
- case 0x00: goto yy2;
- case '"': goto yy17;
- case '\\': goto yy19;
- default: goto yy15;
- }
-yy17:
- ++YYCURSOR;
-#line 56 "ext/pdo/pdo_sql_parser.re"
- { RET(PDO_PARSER_TEXT); }
-#line 221 "ext/pdo/pdo_sql_parser.c"
-yy19:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych <= 0x00) goto yy2;
- goto yy15;
-yy20:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy21:
- switch (yych) {
- case 0x00: goto yy2;
- case '\'': goto yy22;
- case '\\': goto yy24;
- default: goto yy20;
- }
-yy22:
- ++YYCURSOR;
-#line 57 "ext/pdo/pdo_sql_parser.re"
- { RET(PDO_PARSER_TEXT); }
-#line 243 "ext/pdo/pdo_sql_parser.c"
-yy24:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych <= 0x00) goto yy2;
- goto yy20;
-yy25:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- switch (yych) {
- case '\n':
- case '\r': goto yy27;
- default: goto yy25;
- }
-yy27:
-#line 62 "ext/pdo/pdo_sql_parser.re"
- { RET(PDO_PARSER_TEXT); }
-#line 262 "ext/pdo/pdo_sql_parser.c"
-yy28:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- switch (yych) {
- case '*': goto yy38;
- default: goto yy28;
- }
-yy30:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- switch (yych) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case 'A':
- case 'B':
- case 'C':
- case 'D':
- case 'E':
- case 'F':
- case 'G':
- case 'H':
- case 'I':
- case 'J':
- case 'K':
- case 'L':
- case 'M':
- case 'N':
- case 'O':
- case 'P':
- case 'Q':
- case 'R':
- case 'S':
- case 'T':
- case 'U':
- case 'V':
- case 'W':
- case 'X':
- case 'Y':
- case 'Z':
- case '_':
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- case 'i':
- case 'j':
- case 'k':
- case 'l':
- case 'm':
- case 'n':
- case 'o':
- case 'p':
- case 'q':
- case 'r':
- case 's':
- case 't':
- case 'u':
- case 'v':
- case 'w':
- case 'x':
- case 'y':
- case 'z': goto yy30;
- default: goto yy32;
- }
-yy32:
-#line 59 "ext/pdo/pdo_sql_parser.re"
- { RET(PDO_PARSER_BIND); }
-#line 344 "ext/pdo/pdo_sql_parser.c"
-yy33:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- switch (yych) {
- case ':': goto yy33;
- default: goto yy35;
- }
-yy35:
-#line 58 "ext/pdo/pdo_sql_parser.re"
- { RET(PDO_PARSER_TEXT); }
-#line 356 "ext/pdo/pdo_sql_parser.c"
-yy36:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- switch (yych) {
- case '?': goto yy36;
- default: goto yy35;
- }
-yy38:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- switch (yych) {
- case '*': goto yy38;
- case '/': goto yy40;
- default: goto yy28;
- }
-yy40:
- ++YYCURSOR;
- goto yy27;
-}
-#line 64 "ext/pdo/pdo_sql_parser.re"
-
-}
-
-struct placeholder {
- char *pos;
- size_t len;
- size_t qlen; /* quoted length of value */
- char *quoted; /* quoted value */
- int freeq;
- int bindno;
- struct placeholder *next;
-};
-
-static void free_param_name(zval *el) {
- efree(Z_PTR_P(el));
-}
-
-PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
- char **outquery, size_t *outquery_len)
-{
- Scanner s;
- char *ptr, *newbuffer;
- ptrdiff_t t;
- uint32_t bindno = 0;
- int ret = 0;
- size_t newbuffer_len;
- HashTable *params;
- struct pdo_bound_param_data *param;
- int query_type = PDO_PLACEHOLDER_NONE;
- struct placeholder *placeholders = NULL, *placetail = NULL, *plc = NULL;
-
- ptr = *outquery;
- s.cur = inquery;
- s.end = inquery + inquery_len + 1;
-
- /* phase 1: look for args */
- while((t = scan(&s)) != PDO_PARSER_EOI) {
- if (t == PDO_PARSER_BIND || t == PDO_PARSER_BIND_POS) {
- if (t == PDO_PARSER_BIND) {
- ptrdiff_t len = s.cur - s.tok;
- if ((inquery < (s.cur - len)) && isalnum(*(s.cur - len - 1))) {
- continue;
- }
- query_type |= PDO_PLACEHOLDER_NAMED;
- } else {
- query_type |= PDO_PLACEHOLDER_POSITIONAL;
- }
-
- plc = emalloc(sizeof(*plc));
- memset(plc, 0, sizeof(*plc));
- plc->next = NULL;
- plc->pos = s.tok;
- plc->len = s.cur - s.tok;
- plc->bindno = bindno++;
-
- if (placetail) {
- placetail->next = plc;
- } else {
- placeholders = plc;
- }
- placetail = plc;
- }
- }
-
- if (bindno == 0) {
- /* nothing to do; good! */
- return 0;
- }
-
- /* did the query make sense to me? */
- if (query_type == (PDO_PLACEHOLDER_NAMED|PDO_PLACEHOLDER_POSITIONAL)) {
- /* they mixed both types; punt */
- pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "mixed named and positional parameters");
- ret = -1;
- goto clean_up;
- }
-
- if (stmt->supports_placeholders == query_type && !stmt->named_rewrite_template) {
- /* query matches native syntax */
- ret = 0;
- goto clean_up;
- }
-
- if (stmt->named_rewrite_template) {
- /* magic/hack.
- * We we pretend that the query was positional even if
- * it was named so that we fall into the
- * named rewrite case below. Not too pretty,
- * but it works. */
- query_type = PDO_PLACEHOLDER_POSITIONAL;
- }
-
- params = stmt->bound_params;
-
- /* Do we have placeholders but no bound params */
- if (bindno && !params && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
- pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "no parameters were bound");
- ret = -1;
- goto clean_up;
- }
-
- if (params && bindno != zend_hash_num_elements(params) && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
- /* extra bit of validation for instances when same params are bound more than once */
- if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > zend_hash_num_elements(params)) {
- int ok = 1;
- for (plc = placeholders; plc; plc = plc->next) {
- if ((param = zend_hash_str_find_ptr(params, plc->pos, plc->len)) == NULL) {
- ok = 0;
- break;
- }
- }
- if (ok) {
- goto safe;
- }
- }
- pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "number of bound variables does not match number of tokens");
- ret = -1;
- goto clean_up;
- }
-safe:
- /* what are we going to do ? */
- if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
- /* query generation */
-
- newbuffer_len = inquery_len;
-
- /* let's quote all the values */
- for (plc = placeholders; plc; plc = plc->next) {
- if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
- param = zend_hash_index_find_ptr(params, plc->bindno);
- } else {
- param = zend_hash_str_find_ptr(params, plc->pos, plc->len);
- }
- if (param == NULL) {
- /* parameter was not defined */
- ret = -1;
- pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined");
- goto clean_up;
- }
- if (stmt->dbh->methods->quoter) {
- zval *parameter;
- if (Z_ISREF(param->parameter)) {
- parameter = Z_REFVAL(param->parameter);
- } else {
- parameter = &param->parameter;
- }
- if (param->param_type == PDO_PARAM_LOB && Z_TYPE_P(parameter) == IS_RESOURCE) {
- php_stream *stm;
-
- php_stream_from_zval_no_verify(stm, parameter);
- if (stm) {
- zend_string *buf;
-
- buf = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0);
- if (!buf) {
- buf = ZSTR_EMPTY_ALLOC();
- }
- if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf), ZSTR_LEN(buf), &plc->quoted, &plc->qlen,
- param->param_type)) {
- /* bork */
- ret = -1;
- strncpy(stmt->error_code, stmt->dbh->error_code, 6);
- if (buf) {
- zend_string_release_ex(buf, 0);
- }
- goto clean_up;
- }
- if (buf) {
- zend_string_release_ex(buf, 0);
- }
- } else {
- pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource");
- ret = -1;
- goto clean_up;
- }
- plc->freeq = 1;
- } else {
- enum pdo_param_type param_type = param->param_type;
- zend_string *buf = NULL;
-
- /* assume all types are nullable */
- if (Z_TYPE_P(parameter) == IS_NULL) {
- param_type = PDO_PARAM_NULL;
- }
-
- switch (param_type) {
- case PDO_PARAM_BOOL:
- plc->quoted = zend_is_true(parameter) ? "1" : "0";
- plc->qlen = sizeof("1")-1;
- plc->freeq = 0;
- break;
-
- case PDO_PARAM_INT:
- buf = zend_long_to_str(zval_get_long(parameter));
-
- plc->qlen = ZSTR_LEN(buf);
- plc->quoted = estrdup(ZSTR_VAL(buf));
- plc->freeq = 1;
- break;
-
- case PDO_PARAM_NULL:
- plc->quoted = "NULL";
- plc->qlen = sizeof("NULL")-1;
- plc->freeq = 0;
- break;
-
- default:
- buf = zval_get_string(parameter);
- if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf),
- ZSTR_LEN(buf), &plc->quoted, &plc->qlen,
- param_type)) {
- /* bork */
- ret = -1;
- strncpy(stmt->error_code, stmt->dbh->error_code, 6);
- if (buf) {
- zend_string_release_ex(buf, 0);
- }
- goto clean_up;
- }
- plc->freeq = 1;
- }
-
- if (buf) {
- zend_string_release_ex(buf, 0);
- }
- }
- } else {
- zval *parameter;
- if (Z_ISREF(param->parameter)) {
- parameter = Z_REFVAL(param->parameter);
- } else {
- parameter = &param->parameter;
- }
- plc->quoted = Z_STRVAL_P(parameter);
- plc->qlen = Z_STRLEN_P(parameter);
- }
- newbuffer_len += plc->qlen;
- }
-
-rewrite:
- /* allocate output buffer */
- newbuffer = emalloc(newbuffer_len + 1);
- *outquery = newbuffer;
-
- /* and build the query */
- plc = placeholders;
- ptr = inquery;
-
- do {
- t = plc->pos - ptr;
- if (t) {
- memcpy(newbuffer, ptr, t);
- newbuffer += t;
- }
- memcpy(newbuffer, plc->quoted, plc->qlen);
- newbuffer += plc->qlen;
- ptr = plc->pos + plc->len;
-
- plc = plc->next;
- } while (plc);
-
- t = (inquery + inquery_len) - ptr;
- if (t) {
- memcpy(newbuffer, ptr, t);
- newbuffer += t;
- }
- *newbuffer = '\0';
- *outquery_len = newbuffer - *outquery;
-
- ret = 1;
- goto clean_up;
-
- } else if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
- /* rewrite ? to :pdoX */
- char *name, *idxbuf;
- const char *tmpl = stmt->named_rewrite_template ? stmt->named_rewrite_template : ":pdo%d";
- int bind_no = 1;
-
- newbuffer_len = inquery_len;
-
- if (stmt->bound_param_map == NULL) {
- ALLOC_HASHTABLE(stmt->bound_param_map);
- zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
- }
-
- for (plc = placeholders; plc; plc = plc->next) {
- int skip_map = 0;
- char *p;
- name = estrndup(plc->pos, plc->len);
-
- /* check if bound parameter is already available */
- if (!strcmp(name, "?") || (p = zend_hash_str_find_ptr(stmt->bound_param_map, name, plc->len)) == NULL) {
- spprintf(&idxbuf, 0, tmpl, bind_no++);
- } else {
- idxbuf = estrdup(p);
- skip_map = 1;
- }
-
- plc->quoted = idxbuf;
- plc->qlen = strlen(plc->quoted);
- plc->freeq = 1;
- newbuffer_len += plc->qlen;
-
- if (!skip_map && stmt->named_rewrite_template) {
- /* create a mapping */
- zend_hash_str_update_mem(stmt->bound_param_map, name, plc->len, idxbuf, plc->qlen + 1);
- }
-
- /* map number to name */
- zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, idxbuf, plc->qlen + 1);
-
- efree(name);
- }
-
- goto rewrite;
-
- } else {
- /* rewrite :name to ? */
-
- newbuffer_len = inquery_len;
-
- if (stmt->bound_param_map == NULL) {
- ALLOC_HASHTABLE(stmt->bound_param_map);
- zend_hash_init(stmt->bound_param_map, 13, NULL, free_param_name, 0);
- }
-
- for (plc = placeholders; plc; plc = plc->next) {
- char *name;
- name = estrndup(plc->pos, plc->len);
- zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, name, plc->len + 1);
- efree(name);
- plc->quoted = "?";
- plc->qlen = 1;
- }
-
- goto rewrite;
- }
-
-clean_up:
-
- while (placeholders) {
- plc = placeholders;
- placeholders = plc->next;
-
- if (plc->freeq) {
- efree(plc->quoted);
- }
-
- efree(plc);
- }
-
- return ret;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker ft=c
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/phar/phar_path_check.c b/ext/phar/phar_path_check.c
deleted file mode 100644
index 3b9aa06444..0000000000
--- a/ext/phar/phar_path_check.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/* Generated by re2c 1.0.3 */
-#line 1 "ext/phar/phar_path_check.re"
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2007-2018 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt. |
- | 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. |
- +----------------------------------------------------------------------+
- | Authors: Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-#include "phar_internal.h"
-
-phar_path_check_result phar_path_check(char **s, size_t *len, const char **error)
-{
- const unsigned char *p = (const unsigned char*)*s;
- const unsigned char *m;
-
- if (*len == 1 && *p == '.') {
- *error = "current directory reference";
- return pcr_err_curr_dir;
- } else if (*len == 2 && p[0] == '.' && p[1] == '.') {
- *error = "upper directory reference";
- return pcr_err_up_dir;
- }
-
-#define YYCTYPE unsigned char
-#define YYCURSOR p
-#define YYLIMIT p+*len
-#define YYMARKER m
-#define YYFILL(n)
-
-loop:
-
-#line 47 "ext/phar/phar_path_check.c"
-{
- YYCTYPE yych;
- unsigned int yyaccept = 0;
- if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
- yych = *YYCURSOR;
- if (yych <= '[') {
- if (yych <= ')') {
- if (yych <= '\f') {
- if (yych >= 0x01) goto yy4;
- } else {
- if (yych <= '\r') goto yy6;
- if (yych <= 0x19) goto yy4;
- goto yy7;
- }
- } else {
- if (yych <= '/') {
- if (yych <= '*') goto yy9;
- if (yych <= '.') goto yy7;
- goto yy11;
- } else {
- if (yych == '?') goto yy12;
- goto yy7;
- }
- }
- } else {
- if (yych <= 0xEC) {
- if (yych <= 0xC1) {
- if (yych <= '\\') goto yy14;
- if (yych <= 0x7F) goto yy7;
- goto yy4;
- } else {
- if (yych <= 0xDF) goto yy16;
- if (yych <= 0xE0) goto yy17;
- goto yy18;
- }
- } else {
- if (yych <= 0xF0) {
- if (yych <= 0xED) goto yy19;
- if (yych <= 0xEF) goto yy18;
- goto yy20;
- } else {
- if (yych <= 0xF3) goto yy21;
- if (yych <= 0xF4) goto yy22;
- goto yy4;
- }
- }
- }
- ++YYCURSOR;
-#line 93 "ext/phar/phar_path_check.re"
- {
- if (**s == '/') {
- (*s)++;
- (*len)--;
- }
- if ((p - (const unsigned char*)*s) - 1 != *len)
- {
- *error ="illegal character";
- return pcr_err_illegal_char;
- }
- *error = NULL;
- return pcr_is_ok;
- }
-#line 110 "ext/phar/phar_path_check.c"
-yy4:
- ++YYCURSOR;
-yy5:
-#line 106 "ext/phar/phar_path_check.re"
- {
- *error ="illegal character";
- return pcr_err_illegal_char;
- }
-#line 119 "ext/phar/phar_path_check.c"
-yy6:
- yych = *++YYCURSOR;
- if (yych == '\n') goto yy4;
- goto yy5;
-yy7:
- ++YYCURSOR;
-yy8:
-#line 90 "ext/phar/phar_path_check.re"
- {
- goto loop;
- }
-#line 131 "ext/phar/phar_path_check.c"
-yy9:
- ++YYCURSOR;
-#line 78 "ext/phar/phar_path_check.re"
- {
- *error = "star";
- return pcr_err_star;
- }
-#line 139 "ext/phar/phar_path_check.c"
-yy11:
- yyaccept = 0;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= '-') goto yy8;
- if (yych <= '.') goto yy23;
- if (yych <= '/') goto yy25;
- goto yy8;
-yy12:
- ++YYCURSOR;
-#line 82 "ext/phar/phar_path_check.re"
- {
- if (**s == '/') {
- (*s)++;
- }
- *len = (p - (const unsigned char*)*s) -1;
- *error = NULL;
- return pcr_use_query;
- }
-#line 158 "ext/phar/phar_path_check.c"
-yy14:
- ++YYCURSOR;
-#line 74 "ext/phar/phar_path_check.re"
- {
- *error = "back-slash";
- return pcr_err_back_slash;
- }
-#line 166 "ext/phar/phar_path_check.c"
-yy16:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy5;
- if (yych <= 0xBF) goto yy7;
- goto yy5;
-yy17:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x9F) goto yy5;
- if (yych <= 0xBF) goto yy27;
- goto yy5;
-yy18:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy5;
- if (yych <= 0xBF) goto yy27;
- goto yy5;
-yy19:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy5;
- if (yych <= 0x9F) goto yy27;
- goto yy5;
-yy20:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x8F) goto yy5;
- if (yych <= 0xBF) goto yy28;
- goto yy5;
-yy21:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy5;
- if (yych <= 0xBF) goto yy28;
- goto yy5;
-yy22:
- yyaccept = 1;
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych <= 0x7F) goto yy5;
- if (yych <= 0x8F) goto yy28;
- goto yy5;
-yy23:
- yych = *++YYCURSOR;
- if (yych <= 0x00) goto yy29;
- if (yych <= '-') goto yy24;
- if (yych <= '.') goto yy31;
- if (yych <= '/') goto yy29;
-yy24:
- YYCURSOR = YYMARKER;
- if (yyaccept == 0) {
- goto yy8;
- } else {
- goto yy5;
- }
-yy25:
- ++YYCURSOR;
-#line 62 "ext/phar/phar_path_check.re"
- {
- *error = "double slash";
- return pcr_err_double_slash;
- }
-#line 228 "ext/phar/phar_path_check.c"
-yy27:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy24;
- if (yych <= 0xBF) goto yy7;
- goto yy24;
-yy28:
- yych = *++YYCURSOR;
- if (yych <= 0x7F) goto yy24;
- if (yych <= 0xBF) goto yy27;
- goto yy24;
-yy29:
- ++YYCURSOR;
-#line 70 "ext/phar/phar_path_check.re"
- {
- *error = "current directory reference";
- return pcr_err_curr_dir;
- }
-#line 246 "ext/phar/phar_path_check.c"
-yy31:
- yych = *++YYCURSOR;
- if (yych <= 0x00) goto yy32;
- if (yych != '/') goto yy24;
-yy32:
- ++YYCURSOR;
-#line 66 "ext/phar/phar_path_check.re"
- {
- *error = "upper directory reference";
- return pcr_err_up_dir;
- }
-#line 258 "ext/phar/phar_path_check.c"
-}
-#line 110 "ext/phar/phar_path_check.re"
-
-}
diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c
deleted file mode 100644
index fb4a55d2fe..0000000000
--- a/ext/standard/url_scanner_ex.c
+++ /dev/null
@@ -1,1431 +0,0 @@
-/* Generated by re2c 1.0.3 */
-#line 1 "ext/standard/url_scanner_ex.re"
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | 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. |
- +----------------------------------------------------------------------+
- | Author: Sascha Schumann <sascha@schumann.cx> |
- | Yasuo Ohgaki <yohgaki@ohgaki.net> |
- +----------------------------------------------------------------------+
-*/
-
-#include "php.h"
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "SAPI.h"
-#include "php_ini.h"
-#include "php_globals.h"
-#include "php_string.h"
-#define STATE_TAG SOME_OTHER_STATE_TAG
-#include "basic_functions.h"
-#include "url.h"
-#include "html.h"
-#undef STATE_TAG
-
-#define url_scanner url_scanner_ex
-
-#include "zend_smart_str.h"
-
-static void tag_dtor(zval *zv)
-{
- free(Z_PTR_P(zv));
-}
-
-static int php_ini_on_update_tags(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage, int type)
-{
- url_adapt_state_ex_t *ctx;
- char *key;
- char *tmp;
- char *lasts = NULL;
-
- if (type) {
- ctx = &BG(url_adapt_session_ex);
- } else {
- ctx = &BG(url_adapt_output_ex);
- }
-
- tmp = estrndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
-
- if (ctx->tags)
- zend_hash_destroy(ctx->tags);
- else {
- ctx->tags = malloc(sizeof(HashTable));
- if (!ctx->tags) {
- efree(tmp);
- return FAILURE;
- }
- }
-
- zend_hash_init(ctx->tags, 0, NULL, tag_dtor, 1);
-
- for (key = php_strtok_r(tmp, ",", &lasts);
- key;
- key = php_strtok_r(NULL, ",", &lasts)) {
- char *val;
-
- val = strchr(key, '=');
- if (val) {
- char *q;
- size_t keylen;
- zend_string *str;
-
- *val++ = '\0';
- for (q = key; *q; q++) {
- *q = tolower(*q);
- }
- keylen = q - key;
- str = zend_string_init(key, keylen, 1);
- GC_MAKE_PERSISTENT_LOCAL(str);
- zend_hash_add_mem(ctx->tags, str, val, strlen(val)+1);
- zend_string_release_ex(str, 1);
- }
- }
-
- efree(tmp);
-
- return SUCCESS;
-}
-
-static PHP_INI_MH(OnUpdateSessionTags)
-{
- return php_ini_on_update_tags(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage, 1);
-}
-
-static PHP_INI_MH(OnUpdateOutputTags)
-{
- return php_ini_on_update_tags(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage, 0);
-}
-
-static int php_ini_on_update_hosts(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage, int type)
-{
- HashTable *hosts;
- char *key;
- char *tmp;
- char *lasts = NULL;
-
- if (type) {
- hosts = &BG(url_adapt_session_hosts_ht);
- } else {
- hosts = &BG(url_adapt_output_hosts_ht);
- }
- zend_hash_clean(hosts);
-
- /* Use user supplied host whitelist */
- tmp = estrndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
- for (key = php_strtok_r(tmp, ",", &lasts);
- key;
- key = php_strtok_r(NULL, ",", &lasts)) {
- size_t keylen;
- zend_string *tmp_key;
- char *q;
-
- for (q = key; *q; q++) {
- *q = tolower(*q);
- }
- keylen = q - key;
- if (keylen > 0) {
- tmp_key = zend_string_init(key, keylen, 0);
- zend_hash_add_empty_element(hosts, tmp_key);
- zend_string_release_ex(tmp_key, 0);
- }
- }
- efree(tmp);
-
- return SUCCESS;
-}
-
-static PHP_INI_MH(OnUpdateSessionHosts)
-{
- return php_ini_on_update_hosts(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage, 1);
-}
-
-static PHP_INI_MH(OnUpdateOutputHosts)
-{
- return php_ini_on_update_hosts(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage, 0);
-}
-
-/* FIXME: OnUpdate*Hosts cannot set default to $_SERVER['HTTP_HOST'] at startup */
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("session.trans_sid_tags", "a=href,area=href,frame=src,form=", PHP_INI_ALL, OnUpdateSessionTags, url_adapt_session_ex, php_basic_globals, basic_globals)
- STD_PHP_INI_ENTRY("session.trans_sid_hosts", "", PHP_INI_ALL, OnUpdateSessionHosts, url_adapt_session_hosts_ht, php_basic_globals, basic_globals)
- STD_PHP_INI_ENTRY("url_rewriter.tags", "form=", PHP_INI_ALL, OnUpdateOutputTags, url_adapt_session_ex, php_basic_globals, basic_globals)
- STD_PHP_INI_ENTRY("url_rewriter.hosts", "", PHP_INI_ALL, OnUpdateOutputHosts, url_adapt_session_hosts_ht, php_basic_globals, basic_globals)
-PHP_INI_END()
-
-#line 179 "ext/standard/url_scanner_ex.re"
-
-
-#define YYFILL(n) goto done
-#define YYCTYPE unsigned char
-#define YYCURSOR p
-#define YYLIMIT q
-#define YYMARKER r
-
-static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator)
-{
- php_url *url_parts;
-
- smart_str_0(url); /* FIXME: Bug #70480 php_url_parse_ex() crashes by processing chars exceed len */
- url_parts = php_url_parse_ex(ZSTR_VAL(url->s), ZSTR_LEN(url->s));
-
- /* Ignore malformed URLs */
- if (!url_parts) {
- smart_str_append_smart_str(dest, url);
- return;
- }
-
- /* Don't modify URLs of the format "#mark" */
- if (url_parts->fragment && '#' == ZSTR_VAL(url->s)[0]) {
- smart_str_append_smart_str(dest, url);
- php_url_free(url_parts);
- return;
- }
-
- /* Check protocol. Only http/https is allowed. */
- if (url_parts->scheme
- && !zend_string_equals_literal_ci(url_parts->scheme, "http")
- && !zend_string_equals_literal_ci(url_parts->scheme, "https")) {
- smart_str_append_smart_str(dest, url);
- php_url_free(url_parts);
- return;
- }
-
- /* Check host whitelist. If it's not listed, do nothing. */
- if (url_parts->host) {
- zend_string *tmp = zend_string_tolower(url_parts->host);
- if (!zend_hash_exists(&BG(url_adapt_session_hosts_ht), tmp)) {
- zend_string_release_ex(tmp, 0);
- smart_str_append_smart_str(dest, url);
- php_url_free(url_parts);
- return;
- }
- zend_string_release_ex(tmp, 0);
- }
-
- /*
- * When URL does not have path and query string add "/?".
- * i.e. If URL is only "?foo=bar", should not add "/?".
- */
- if (!url_parts->path && !url_parts->query && !url_parts->fragment) {
- /* URL is http://php.net or like */
- smart_str_append_smart_str(dest, url);
- smart_str_appendc(dest, '/');
- smart_str_appendc(dest, '?');
- smart_str_append_smart_str(dest, url_app);
- php_url_free(url_parts);
- return;
- }
-
- if (url_parts->scheme) {
- smart_str_appends(dest, ZSTR_VAL(url_parts->scheme));
- smart_str_appends(dest, "://");
- } else if (*(ZSTR_VAL(url->s)) == '/' && *(ZSTR_VAL(url->s)+1) == '/') {
- smart_str_appends(dest, "//");
- }
- if (url_parts->user) {
- smart_str_appends(dest, ZSTR_VAL(url_parts->user));
- if (url_parts->pass) {
- smart_str_appends(dest, ZSTR_VAL(url_parts->pass));
- smart_str_appendc(dest, ':');
- }
- smart_str_appendc(dest, '@');
- }
- if (url_parts->host) {
- smart_str_appends(dest, ZSTR_VAL(url_parts->host));
- }
- if (url_parts->port) {
- smart_str_appendc(dest, ':');
- smart_str_append_unsigned(dest, (long)url_parts->port);
- }
- if (url_parts->path) {
- smart_str_appends(dest, ZSTR_VAL(url_parts->path));
- }
- smart_str_appendc(dest, '?');
- if (url_parts->query) {
- smart_str_appends(dest, ZSTR_VAL(url_parts->query));
- smart_str_appends(dest, separator);
- smart_str_append_smart_str(dest, url_app);
- } else {
- smart_str_append_smart_str(dest, url_app);
- }
- if (url_parts->fragment) {
- smart_str_appendc(dest, '#');
- smart_str_appends(dest, ZSTR_VAL(url_parts->fragment));
- }
- php_url_free(url_parts);
-}
-
-enum {
- TAG_NORMAL = 0,
- TAG_FORM
-};
-
-enum {
- ATTR_NORMAL = 0,
- ATTR_ACTION
-};
-
-#undef YYFILL
-#undef YYCTYPE
-#undef YYCURSOR
-#undef YYLIMIT
-#undef YYMARKER
-
-static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type)
-{
- char f = 0;
-
- /* arg.s is string WITHOUT NUL.
- To avoid partial match, NUL is added here */
- ZSTR_VAL(ctx->arg.s)[ZSTR_LEN(ctx->arg.s)] = '\0';
- if (!strcasecmp(ZSTR_VAL(ctx->arg.s), ctx->lookup_data)) {
- f = 1;
- }
-
- if (quotes) {
- smart_str_appendc(&ctx->result, type);
- }
- if (f) {
- append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output);
- } else {
- smart_str_append_smart_str(&ctx->result, &ctx->val);
- }
- if (quotes) {
- smart_str_appendc(&ctx->result, type);
- }
-}
-
-enum {
- STATE_PLAIN = 0,
- STATE_TAG,
- STATE_NEXT_ARG,
- STATE_ARG,
- STATE_BEFORE_VAL,
- STATE_VAL
-};
-
-#define YYFILL(n) goto stop
-#define YYCTYPE unsigned char
-#define YYCURSOR xp
-#define YYLIMIT end
-#define YYMARKER q
-#define STATE ctx->state
-
-#define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR
-#define STD_ARGS ctx, start, xp
-
-#if SCANNER_DEBUG
-#define scdebug(x) printf x
-#else
-#define scdebug(x)
-#endif
-
-static inline void passthru(STD_PARA)
-{
- scdebug(("appending %d chars, starting with %c\n", YYCURSOR-start, *start));
- smart_str_appendl(&ctx->result, start, YYCURSOR - start);
-}
-
-
-static int check_http_host(char *target)
-{
- zval *host, *tmp;
- zend_string *host_tmp;
- char *colon;
-
- if ((tmp = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_SERVER"))) &&
- Z_TYPE_P(tmp) == IS_ARRAY &&
- (host = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("HTTP_HOST"))) &&
- Z_TYPE_P(host) == IS_STRING) {
- host_tmp = zend_string_init(Z_STRVAL_P(host), Z_STRLEN_P(host), 0);
- /* HTTP_HOST could be 'localhost:8888' etc. */
- colon = strchr(ZSTR_VAL(host_tmp), ':');
- if (colon) {
- ZSTR_LEN(host_tmp) = colon - ZSTR_VAL(host_tmp);
- ZSTR_VAL(host_tmp)[ZSTR_LEN(host_tmp)] = '\0';
- }
- if (!strcasecmp(ZSTR_VAL(host_tmp), target)) {
- zend_string_release_ex(host_tmp, 0);
- return SUCCESS;
- }
- zend_string_release_ex(host_tmp, 0);
- }
- return FAILURE;
-}
-
-static int check_host_whitelist(url_adapt_state_ex_t *ctx)
-{
- php_url *url_parts = NULL;
- HashTable *allowed_hosts = ctx->type ? &BG(url_adapt_session_hosts_ht) : &BG(url_adapt_output_hosts_ht);
-
- ZEND_ASSERT(ctx->tag_type == TAG_FORM);
-
- if (ctx->attr_val.s && ZSTR_LEN(ctx->attr_val.s)) {
- url_parts = php_url_parse_ex(ZSTR_VAL(ctx->attr_val.s), ZSTR_LEN(ctx->attr_val.s));
- } else {
- return SUCCESS; /* empty URL is valid */
- }
-
- if (!url_parts) {
- return FAILURE;
- }
- if (url_parts->scheme) {
- /* Only http/https should be handled.
- A bit hacky check this here, but saves a URL parse. */
- if (!zend_string_equals_literal_ci(url_parts->scheme, "http") &&
- !zend_string_equals_literal_ci(url_parts->scheme, "https")) {
- php_url_free(url_parts);
- return FAILURE;
- }
- }
- if (!url_parts->host) {
- php_url_free(url_parts);
- return SUCCESS;
- }
- if (!zend_hash_num_elements(allowed_hosts) &&
- check_http_host(ZSTR_VAL(url_parts->host)) == SUCCESS) {
- php_url_free(url_parts);
- return SUCCESS;
- }
- if (!zend_hash_find(allowed_hosts, url_parts->host)) {
- php_url_free(url_parts);
- return FAILURE;
- }
- php_url_free(url_parts);
- return SUCCESS;
-}
-
-/*
- * This function appends a hidden input field after a <form>.
- */
-static void handle_form(STD_PARA)
-{
- int doit = 0;
-
- if (ZSTR_LEN(ctx->form_app.s) > 0) {
- switch (ZSTR_LEN(ctx->tag.s)) {
- case sizeof("form") - 1:
- if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))
- && check_host_whitelist(ctx) == SUCCESS) {
- doit = 1;
- }
- break;
- }
- }
-
- if (doit) {
- smart_str_append_smart_str(&ctx->result, &ctx->form_app);
- }
-}
-
-/*
- * HANDLE_TAG copies the HTML Tag and checks whether we
- * 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.
- */
-
-static inline void handle_tag(STD_PARA)
-{
- int ok = 0;
- unsigned int i;
-
- if (ctx->tag.s) {
- ZSTR_LEN(ctx->tag.s) = 0;
- }
- smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
- 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]);
- /* intentionally using str_find here, in case the hash value is set, but the string val is changed later */
- if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL) {
- ok = 1;
- if (ZSTR_LEN(ctx->tag.s) == sizeof("form")-1
- && !strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))) {
- ctx->tag_type = TAG_FORM;
- } else {
- ctx->tag_type = TAG_NORMAL;
- }
- }
- STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
-}
-
-static inline void handle_arg(STD_PARA)
-{
- if (ctx->arg.s) {
- ZSTR_LEN(ctx->arg.s) = 0;
- }
- smart_str_appendl(&ctx->arg, start, YYCURSOR - start);
- if (ctx->tag_type == TAG_FORM &&
- strncasecmp(ZSTR_VAL(ctx->arg.s), "action", ZSTR_LEN(ctx->arg.s)) == 0) {
- ctx->attr_type = ATTR_ACTION;
- } else {
- ctx->attr_type = ATTR_NORMAL;
- }
-}
-
-static inline void handle_val(STD_PARA, char quotes, char type)
-{
- smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2);
- if (ctx->tag_type == TAG_FORM && ctx->attr_type == ATTR_ACTION) {
- smart_str_setl(&ctx->attr_val, start + quotes, YYCURSOR - start - quotes * 2);
- }
- tag_arg(ctx, quotes, type);
-}
-
-static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen)
-{
- char *end, *q;
- char *xp;
- char *start;
- size_t rest;
-
- smart_str_appendl(&ctx->buf, newdata, newlen);
-
- YYCURSOR = ZSTR_VAL(ctx->buf.s);
- YYLIMIT = ZSTR_VAL(ctx->buf.s) + ZSTR_LEN(ctx->buf.s);
-
- 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;
- }
-
-
-state_plain_begin:
- STATE = STATE_PLAIN;
-
-state_plain:
- start = YYCURSOR;
-
-#line 524 "ext/standard/url_scanner_ex.c"
-{
- YYCTYPE yych;
- static const unsigned char yybm[] = {
- 128, 128, 128, 128, 128, 128, 128, 128,
- 128, 128, 128, 128, 128, 128, 128, 128,
- 128, 128, 128, 128, 128, 128, 128, 128,
- 128, 128, 128, 128, 128, 128, 128, 128,
- 128, 128, 128, 128, 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,
- };
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy2;
- }
- goto yy5;
-yy2:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy2;
- }
-#line 527 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); goto state_plain; }
-#line 576 "ext/standard/url_scanner_ex.c"
-yy5:
- ++YYCURSOR;
-#line 526 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
-#line 581 "ext/standard/url_scanner_ex.c"
-}
-#line 528 "ext/standard/url_scanner_ex.re"
-
-
-state_tag:
- start = YYCURSOR;
-
-#line 589 "ext/standard/url_scanner_ex.c"
-{
- YYCTYPE yych;
- static const unsigned char yybm[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 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,
- };
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy11;
- }
- ++YYCURSOR;
-#line 534 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); goto state_plain_begin; }
-#line 634 "ext/standard/url_scanner_ex.c"
-yy11:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy11;
- }
-#line 533 "ext/standard/url_scanner_ex.re"
- { handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
-#line 644 "ext/standard/url_scanner_ex.c"
-}
-#line 535 "ext/standard/url_scanner_ex.re"
-
-
-state_next_arg_begin:
- STATE = STATE_NEXT_ARG;
-
-state_next_arg:
- start = YYCURSOR;
-
-#line 655 "ext/standard/url_scanner_ex.c"
-{
- YYCTYPE yych;
- static const unsigned char yybm[] = {
- 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,
- };
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy18;
- }
- if (yych <= '>') {
- if (yych == '/') goto yy21;
- if (yych >= '>') goto yy22;
- } else {
- if (yych <= 'Z') {
- if (yych >= 'A') goto yy24;
- } else {
- if (yych <= '`') goto yy16;
- if (yych <= 'z') goto yy24;
- }
- }
-yy16:
- ++YYCURSOR;
-yy17:
-#line 546 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); goto state_plain_begin; }
-#line 713 "ext/standard/url_scanner_ex.c"
-yy18:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy18;
- }
-#line 544 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); goto state_next_arg; }
-#line 723 "ext/standard/url_scanner_ex.c"
-yy21:
- yych = *++YYCURSOR;
- if (yych != '>') goto yy17;
-yy22:
- ++YYCURSOR;
-#line 543 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
-#line 731 "ext/standard/url_scanner_ex.c"
-yy24:
- ++YYCURSOR;
-#line 545 "ext/standard/url_scanner_ex.re"
- { --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
-#line 736 "ext/standard/url_scanner_ex.c"
-}
-#line 547 "ext/standard/url_scanner_ex.re"
-
-
-state_arg:
- start = YYCURSOR;
-
-#line 744 "ext/standard/url_scanner_ex.c"
-{
- YYCTYPE yych;
- static const unsigned char yybm[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 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,
- };
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych <= '@') goto yy28;
- if (yych <= 'Z') goto yy30;
- if (yych <= '`') goto yy28;
- if (yych <= 'z') goto yy30;
-yy28:
- ++YYCURSOR;
-#line 553 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; }
-#line 791 "ext/standard/url_scanner_ex.c"
-yy30:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy30;
- }
-#line 552 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
-#line 801 "ext/standard/url_scanner_ex.c"
-}
-#line 554 "ext/standard/url_scanner_ex.re"
-
-
-state_before_val:
- start = YYCURSOR;
-
-#line 809 "ext/standard/url_scanner_ex.c"
-{
- YYCTYPE yych;
- static const unsigned char yybm[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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,
- };
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yych == ' ') goto yy37;
- if (yych == '=') goto yy38;
- ++YYCURSOR;
-yy36:
-#line 560 "ext/standard/url_scanner_ex.re"
- { --YYCURSOR; goto state_next_arg_begin; }
-#line 854 "ext/standard/url_scanner_ex.c"
-yy37:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ' ') goto yy41;
- if (yych != '=') goto yy36;
-yy38:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy38;
- }
-#line 559 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
-#line 868 "ext/standard/url_scanner_ex.c"
-yy41:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych == ' ') goto yy41;
- if (yych == '=') goto yy38;
- YYCURSOR = YYMARKER;
- goto yy36;
-}
-#line 561 "ext/standard/url_scanner_ex.re"
-
-
-
-state_val:
- start = YYCURSOR;
-
-#line 885 "ext/standard/url_scanner_ex.c"
-{
- YYCTYPE yych;
- static const unsigned char yybm[] = {
- 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, 128, 224, 224, 224, 224, 64,
- 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,
- };
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 32) {
- goto yy46;
- }
- if (yych <= ' ') goto yy49;
- if (yych <= '"') goto yy51;
- if (yych <= '\'') goto yy52;
- goto yy49;
-yy46:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 32) {
- goto yy46;
- }
-#line 569 "ext/standard/url_scanner_ex.re"
- { handle_val(STD_ARGS, 0, ' '); goto state_next_arg_begin; }
-#line 940 "ext/standard/url_scanner_ex.c"
-yy49:
- ++YYCURSOR;
-yy50:
-#line 570 "ext/standard/url_scanner_ex.re"
- { passthru(STD_ARGS); goto state_next_arg_begin; }
-#line 946 "ext/standard/url_scanner_ex.c"
-yy51:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == '>') goto yy50;
- goto yy54;
-yy52:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == '>') goto yy50;
- goto yy59;
-yy53:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy54:
- if (yybm[0+yych] & 64) {
- goto yy53;
- }
- if (yych <= '"') goto yy56;
-yy55:
- YYCURSOR = YYMARKER;
- goto yy50;
-yy56:
- ++YYCURSOR;
-#line 567 "ext/standard/url_scanner_ex.re"
- { handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
-#line 971 "ext/standard/url_scanner_ex.c"
-yy58:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
-yy59:
- if (yybm[0+yych] & 128) {
- goto yy58;
- }
- if (yych >= '(') goto yy55;
- ++YYCURSOR;
-#line 568 "ext/standard/url_scanner_ex.re"
- { handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
-#line 984 "ext/standard/url_scanner_ex.c"
-}
-#line 571 "ext/standard/url_scanner_ex.re"
-
-
-stop:
- if (YYLIMIT < start) {
- /* XXX: Crash avoidance. Need to work with reporter to figure out what goes wrong */
- 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));
- }
-
- if (rest) memmove(ZSTR_VAL(ctx->buf.s), start, rest);
- ZSTR_LEN(ctx->buf.s) = rest;
-}
-
-
-PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen, int encode)
-{
- char *result;
- smart_str surl = {0};
- smart_str buf = {0};
- smart_str url_app = {0};
- zend_string *encoded;
-
- smart_str_appendl(&surl, url, urllen);
-
- if (encode) {
- encoded = php_raw_url_encode(name, strlen(name));
- smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
- zend_string_free(encoded);
- } else {
- smart_str_appends(&url_app, name);
- }
- smart_str_appendc(&url_app, '=');
- if (encode) {
- encoded = php_raw_url_encode(value, strlen(value));
- smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
- zend_string_free(encoded);
- } else {
- smart_str_appends(&url_app, value);
- }
-
- append_modified_url(&surl, &buf, &url_app, PG(arg_separator).output);
-
- smart_str_0(&buf);
- if (newlen) *newlen = ZSTR_LEN(buf.s);
- result = estrndup(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s));
-
- smart_str_free(&url_app);
- smart_str_free(&buf);
-
- return result;
-}
-
-
-static char *url_adapt_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush, url_adapt_state_ex_t *ctx)
-{
- char *retval;
-
- xx_mainloop(ctx, src, srclen);
-
- if (!ctx->result.s) {
- smart_str_appendl(&ctx->result, "", 0);
- *newlen = 0;
- } else {
- *newlen = ZSTR_LEN(ctx->result.s);
- }
- smart_str_0(&ctx->result);
- if (do_flush) {
- smart_str_append(&ctx->result, ctx->buf.s);
- *newlen += ZSTR_LEN(ctx->buf.s);
- smart_str_free(&ctx->buf);
- smart_str_free(&ctx->val);
- smart_str_free(&ctx->attr_val);
- }
- retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
- smart_str_free(&ctx->result);
- return retval;
-}
-
-static int php_url_scanner_ex_activate(int type)
-{
- url_adapt_state_ex_t *ctx;
-
- if (type) {
- ctx = &BG(url_adapt_session_ex);
- } else {
- ctx = &BG(url_adapt_output_ex);
- }
-
- memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags));
-
- return SUCCESS;
-}
-
-static int php_url_scanner_ex_deactivate(int type)
-{
- url_adapt_state_ex_t *ctx;
-
- if (type) {
- ctx = &BG(url_adapt_session_ex);
- } else {
- ctx = &BG(url_adapt_output_ex);
- }
-
- smart_str_free(&ctx->result);
- smart_str_free(&ctx->buf);
- smart_str_free(&ctx->tag);
- smart_str_free(&ctx->arg);
- smart_str_free(&ctx->attr_val);
-
- return SUCCESS;
-}
-
-static inline void php_url_scanner_session_handler_impl(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode, int type)
-{
- size_t len;
- url_adapt_state_ex_t *url_state;
-
- if (type) {
- url_state = &BG(url_adapt_session_ex);
- } else {
- url_state = &BG(url_adapt_output_ex);
- }
-
- if (ZSTR_LEN(url_state->url_app.s) != 0) {
- *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), url_state);
- if (sizeof(uint) < sizeof(size_t)) {
- if (len > UINT_MAX)
- len = UINT_MAX;
- }
- *handled_output_len = len;
- } else if (ZSTR_LEN(url_state->url_app.s) == 0) {
- url_adapt_state_ex_t *ctx = url_state;
- if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) {
- smart_str_append(&ctx->result, ctx->buf.s);
- smart_str_appendl(&ctx->result, output, output_len);
-
- *handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
- *handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len;
-
- smart_str_free(&ctx->buf);
- smart_str_free(&ctx->result);
- } else {
- *handled_output = estrndup(output, *handled_output_len = output_len);
- }
- } else {
- *handled_output = NULL;
- }
-}
-
-static void php_url_scanner_session_handler(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode)
-{
- php_url_scanner_session_handler_impl(output, output_len, handled_output, handled_output_len, mode, 1);
-}
-
-static void php_url_scanner_output_handler(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode)
-{
- php_url_scanner_session_handler_impl(output, output_len, handled_output, handled_output_len, mode, 0);
-}
-
-static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char *value, size_t value_len, int encode, int type)
-{
- smart_str sname = {0};
- smart_str svalue = {0};
- smart_str hname = {0};
- smart_str hvalue = {0};
- zend_string *encoded;
- url_adapt_state_ex_t *url_state;
- php_output_handler_func_t handler;
-
- if (type) {
- url_state = &BG(url_adapt_session_ex);
- handler = php_url_scanner_session_handler;
- } else {
- url_state = &BG(url_adapt_output_ex);
- handler = php_url_scanner_output_handler;
- }
-
- if (!url_state->active) {
- php_url_scanner_ex_activate(type);
- php_output_start_internal(ZEND_STRL("URL-Rewriter"), handler, 0, PHP_OUTPUT_HANDLER_STDFLAGS);
- url_state->active = 1;
- }
-
- if (url_state->url_app.s && ZSTR_LEN(url_state->url_app.s) != 0) {
- smart_str_appends(&url_state->url_app, PG(arg_separator).output);
- }
-
- if (encode) {
- encoded = php_raw_url_encode(name, name_len);
- smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
- encoded = php_raw_url_encode(value, value_len);
- smart_str_appendl(&svalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
- encoded = php_escape_html_entities_ex((unsigned char*)name, name_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), 0);
- smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
- encoded = php_escape_html_entities_ex((unsigned char*)value, value_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), 0);
- smart_str_appendl(&hvalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
- } else {
- smart_str_appendl(&sname, name, name_len);
- smart_str_appendl(&svalue, value, value_len);
- smart_str_appendl(&hname, name, name_len);
- smart_str_appendl(&hvalue, value, value_len);
- }
-
- smart_str_append_smart_str(&url_state->url_app, &sname);
- smart_str_appendc(&url_state->url_app, '=');
- smart_str_append_smart_str(&url_state->url_app, &svalue);
-
- smart_str_appends(&url_state->form_app, "<input type=\"hidden\" name=\"");
- smart_str_append_smart_str(&url_state->form_app, &hname);
- smart_str_appends(&url_state->form_app, "\" value=\"");
- smart_str_append_smart_str(&url_state->form_app, &hvalue);
- smart_str_appends(&url_state->form_app, "\" />");
-
- smart_str_free(&sname);
- smart_str_free(&svalue);
- smart_str_free(&hname);
- smart_str_free(&hvalue);
-
- return SUCCESS;
-}
-
-
-PHPAPI int php_url_scanner_add_session_var(char *name, size_t name_len, char *value, size_t value_len, int encode)
-{
- return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 1);
-}
-
-
-PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int encode)
-{
- return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 0);
-}
-
-
-static inline void php_url_scanner_reset_vars_impl(int type) {
- url_adapt_state_ex_t *url_state;
-
- if (type) {
- url_state = &BG(url_adapt_session_ex);
- } else {
- url_state = &BG(url_adapt_output_ex);
- }
-
- if (url_state->form_app.s) {
- ZSTR_LEN(url_state->form_app.s) = 0;
- }
- if (url_state->url_app.s) {
- ZSTR_LEN(url_state->url_app.s) = 0;
- }
-}
-
-
-PHPAPI int php_url_scanner_reset_session_vars(void)
-{
- php_url_scanner_reset_vars_impl(1);
- return SUCCESS;
-}
-
-
-PHPAPI int php_url_scanner_reset_vars(void)
-{
- php_url_scanner_reset_vars_impl(0);
- return SUCCESS;
-}
-
-
-static inline int php_url_scanner_reset_var_impl(zend_string *name, int encode, int type)
-{
- char *start, *end, *limit;
- size_t separator_len;
- smart_str sname = {0};
- smart_str hname = {0};
- smart_str url_app = {0};
- smart_str form_app = {0};
- zend_string *encoded;
- int ret = SUCCESS;
- zend_bool sep_removed = 0;
- url_adapt_state_ex_t *url_state;
-
- if (type) {
- url_state = &BG(url_adapt_session_ex);
- } else {
- url_state = &BG(url_adapt_output_ex);
- }
-
- /* Short circuit check. Only check url_app. */
- if (!url_state->url_app.s || !ZSTR_LEN(url_state->url_app.s)) {
- return SUCCESS;
- }
-
- if (encode) {
- encoded = php_raw_url_encode(ZSTR_VAL(name), ZSTR_LEN(name));
- smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
- zend_string_free(encoded);
- encoded = php_escape_html_entities_ex((unsigned char *)ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), 0);
- smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
- zend_string_free(encoded);
- } else {
- smart_str_appendl(&sname, ZSTR_VAL(name), ZSTR_LEN(name));
- smart_str_appendl(&hname, ZSTR_VAL(name), ZSTR_LEN(name));
- }
- smart_str_0(&sname);
- smart_str_0(&hname);
-
- smart_str_append_smart_str(&url_app, &sname);
- smart_str_appendc(&url_app, '=');
- smart_str_0(&url_app);
-
- smart_str_appends(&form_app, "<input type=\"hidden\" name=\"");
- smart_str_append_smart_str(&form_app, &hname);
- smart_str_appends(&form_app, "\" value=\"");
- smart_str_0(&form_app);
-
- /* Short circuit check. Only check url_app. */
- start = (char *) php_memnstr(ZSTR_VAL(url_state->url_app.s),
- ZSTR_VAL(url_app.s), ZSTR_LEN(url_app.s),
- ZSTR_VAL(url_state->url_app.s) + ZSTR_LEN(url_state->url_app.s));
- if (!start) {
- ret = FAILURE;
- goto finish;
- }
-
- /* Get end of url var */
- limit = ZSTR_VAL(url_state->url_app.s) + ZSTR_LEN(url_state->url_app.s);
- end = start + ZSTR_LEN(url_app.s);
- separator_len = strlen(PG(arg_separator).output);
- while (end < limit) {
- if (!memcmp(end, PG(arg_separator).output, separator_len)) {
- end += separator_len;
- sep_removed = 1;
- break;
- }
- end++;
- }
- /* Remove all when this is the only rewrite var */
- if (ZSTR_LEN(url_state->url_app.s) == end - start) {
- php_url_scanner_reset_vars_impl(type);
- goto finish;
- }
- /* Check preceding separator */
- if (!sep_removed
- && (size_t)(start - PG(arg_separator).output) >= separator_len
- && !memcmp(start - separator_len, PG(arg_separator).output, separator_len)) {
- start -= separator_len;
- }
- /* Remove partially */
- memmove(start, end,
- ZSTR_LEN(url_state->url_app.s) - (end - ZSTR_VAL(url_state->url_app.s)));
- ZSTR_LEN(url_state->url_app.s) -= end - start;
- ZSTR_VAL(url_state->url_app.s)[ZSTR_LEN(url_state->url_app.s)] = '\0';
-
- /* Remove form var */
- start = (char *) php_memnstr(ZSTR_VAL(url_state->form_app.s),
- ZSTR_VAL(form_app.s), ZSTR_LEN(form_app.s),
- ZSTR_VAL(url_state->form_app.s) + ZSTR_LEN(url_state->form_app.s));
- if (!start) {
- /* Should not happen */
- ret = FAILURE;
- php_url_scanner_reset_vars_impl(type);
- goto finish;
- }
- /* Get end of form var */
- limit = ZSTR_VAL(url_state->form_app.s) + ZSTR_LEN(url_state->form_app.s);
- end = start + ZSTR_LEN(form_app.s);
- while (end < limit) {
- if (*end == '>') {
- end += 1;
- break;
- }
- end++;
- }
- /* Remove partially */
- memmove(start, end,
- ZSTR_LEN(url_state->form_app.s) - (end - ZSTR_VAL(url_state->form_app.s)));
- ZSTR_LEN(url_state->form_app.s) -= end - start;
- ZSTR_VAL(url_state->form_app.s)[ZSTR_LEN(url_state->form_app.s)] = '\0';
-
-finish:
- smart_str_free(&url_app);
- smart_str_free(&form_app);
- smart_str_free(&sname);
- smart_str_free(&hname);
- return ret;
-}
-
-
-PHPAPI int php_url_scanner_reset_session_var(zend_string *name, int encode)
-{
- return php_url_scanner_reset_var_impl(name, encode, 1);
-}
-
-
-PHPAPI int php_url_scanner_reset_var(zend_string *name, int encode)
-{
- return php_url_scanner_reset_var_impl(name, encode, 0);
-}
-
-
-PHP_MINIT_FUNCTION(url_scanner)
-{
- REGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(url_scanner)
-{
- UNREGISTER_INI_ENTRIES();
-
- return SUCCESS;
-}
-
-PHP_RINIT_FUNCTION(url_scanner)
-{
- BG(url_adapt_session_ex).active = 0;
- BG(url_adapt_session_ex).tag_type = 0;
- BG(url_adapt_session_ex).attr_type = 0;
- BG(url_adapt_output_ex).active = 0;
- BG(url_adapt_output_ex).tag_type = 0;
- BG(url_adapt_output_ex).attr_type = 0;
- return SUCCESS;
-}
-
-PHP_RSHUTDOWN_FUNCTION(url_scanner)
-{
- if (BG(url_adapt_session_ex).active) {
- php_url_scanner_ex_deactivate(1);
- BG(url_adapt_session_ex).active = 0;
- BG(url_adapt_session_ex).tag_type = 0;
- BG(url_adapt_session_ex).attr_type = 0;
- }
- smart_str_free(&BG(url_adapt_session_ex).form_app);
- smart_str_free(&BG(url_adapt_session_ex).url_app);
-
- if (BG(url_adapt_output_ex).active) {
- php_url_scanner_ex_deactivate(0);
- BG(url_adapt_output_ex).active = 0;
- BG(url_adapt_output_ex).tag_type = 0;
- BG(url_adapt_output_ex).attr_type = 0;
- }
- smart_str_free(&BG(url_adapt_output_ex).form_app);
- smart_str_free(&BG(url_adapt_output_ex).url_app);
-
- return SUCCESS;
-}
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
deleted file mode 100644
index 3c1c18a700..0000000000
--- a/ext/standard/var_unserializer.c
+++ /dev/null
@@ -1,1500 +0,0 @@
-/* Generated by re2c 1.0.3 */
-#line 1 "ext/standard/var_unserializer.re"
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | 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. |
- +----------------------------------------------------------------------+
- | Author: Sascha Schumann <sascha@schumann.cx> |
- +----------------------------------------------------------------------+
-*/
-
-#include "php.h"
-#include "ext/standard/php_var.h"
-#include "php_incomplete_class.h"
-#include "zend_portability.h"
-
-struct php_unserialize_data {
- void *first;
- void *last;
- void *first_dtor;
- void *last_dtor;
- HashTable *allowed_classes;
-};
-
-PHPAPI php_unserialize_data_t php_var_unserialize_init() {
- php_unserialize_data_t d;
- /* fprintf(stderr, "UNSERIALIZE_INIT == lock: %u, level: %u\n", BG(serialize_lock), BG(unserialize).level); */
- if (BG(serialize_lock) || !BG(unserialize).level) {
- d = ecalloc(1, sizeof(struct php_unserialize_data));
- if (!BG(serialize_lock)) {
- BG(unserialize).data = d;
- BG(unserialize).level = 1;
- }
- } else {
- d = BG(unserialize).data;
- ++BG(unserialize).level;
- }
- return d;
-}
-
-PHPAPI void php_var_unserialize_destroy(php_unserialize_data_t d) {
- /* fprintf(stderr, "UNSERIALIZE_DESTROY == lock: %u, level: %u\n", BG(serialize_lock), BG(unserialize).level); */
- if (BG(serialize_lock) || BG(unserialize).level == 1) {
- var_destroy(&d);
- efree(d);
- }
- if (!BG(serialize_lock) && !--BG(unserialize).level) {
- BG(unserialize).data = NULL;
- }
-}
-
-PHPAPI HashTable *php_var_unserialize_get_allowed_classes(php_unserialize_data_t d) {
- return d->allowed_classes;
-}
-PHPAPI void php_var_unserialize_set_allowed_classes(php_unserialize_data_t d, HashTable *classes) {
- d->allowed_classes = classes;
-}
-
-
-/* {{{ reference-handling for unserializer: var_* */
-#define VAR_ENTRIES_MAX 1024
-#define VAR_ENTRIES_DBG 0
-
-/* VAR_FLAG used in var_dtor entries to signify an entry on which __wakeup should be called */
-#define VAR_WAKEUP_FLAG 1
-
-typedef struct {
- zval *data[VAR_ENTRIES_MAX];
- zend_long used_slots;
- void *next;
-} var_entries;
-
-typedef struct {
- zval data[VAR_ENTRIES_MAX];
- zend_long used_slots;
- void *next;
-} var_dtor_entries;
-
-static inline void var_push(php_unserialize_data_t *var_hashx, zval *rval)
-{
- var_entries *var_hash = (*var_hashx)->last;
-#if VAR_ENTRIES_DBG
- fprintf(stderr, "var_push(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_P(rval));
-#endif
-
- if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) {
- var_hash = emalloc(sizeof(var_entries));
- var_hash->used_slots = 0;
- var_hash->next = 0;
-
- if (!(*var_hashx)->first) {
- (*var_hashx)->first = var_hash;
- } else {
- ((var_entries *) (*var_hashx)->last)->next = var_hash;
- }
-
- (*var_hashx)->last = var_hash;
- }
-
- var_hash->data[var_hash->used_slots++] = rval;
-}
-
-PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval *rval)
-{
- zval *tmp_var = var_tmp_var(var_hashx);
- if (!tmp_var) {
- return;
- }
- ZVAL_COPY(tmp_var, rval);
-}
-
-PHPAPI zval *var_tmp_var(php_unserialize_data_t *var_hashx)
-{
- var_dtor_entries *var_hash;
-
- if (!var_hashx || !*var_hashx) {
- return NULL;
- }
-
- var_hash = (*var_hashx)->last_dtor;
- if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) {
- var_hash = emalloc(sizeof(var_dtor_entries));
- var_hash->used_slots = 0;
- var_hash->next = 0;
-
- if (!(*var_hashx)->first_dtor) {
- (*var_hashx)->first_dtor = var_hash;
- } else {
- ((var_dtor_entries *) (*var_hashx)->last_dtor)->next = var_hash;
- }
-
- (*var_hashx)->last_dtor = var_hash;
- }
- ZVAL_UNDEF(&var_hash->data[var_hash->used_slots]);
- Z_EXTRA(var_hash->data[var_hash->used_slots]) = 0;
- return &var_hash->data[var_hash->used_slots++];
-}
-
-PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nzval)
-{
- zend_long i;
- var_entries *var_hash = (*var_hashx)->first;
-#if VAR_ENTRIES_DBG
- fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_P(nzval));
-#endif
-
- while (var_hash) {
- for (i = 0; i < var_hash->used_slots; i++) {
- if (var_hash->data[i] == ozval) {
- var_hash->data[i] = nzval;
- /* do not break here */
- }
- }
- var_hash = var_hash->next;
- }
-}
-
-static zval *var_access(php_unserialize_data_t *var_hashx, zend_long id)
-{
- var_entries *var_hash = (*var_hashx)->first;
-#if VAR_ENTRIES_DBG
- fprintf(stderr, "var_access(%ld): %ld\n", var_hash?var_hash->used_slots:-1L, id);
-#endif
-
- while (id >= VAR_ENTRIES_MAX && var_hash && var_hash->used_slots == VAR_ENTRIES_MAX) {
- var_hash = var_hash->next;
- id -= VAR_ENTRIES_MAX;
- }
-
- if (!var_hash) return NULL;
-
- if (id < 0 || id >= var_hash->used_slots) return NULL;
-
- return var_hash->data[id];
-}
-
-PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
-{
- void *next;
- zend_long i;
- var_entries *var_hash = (*var_hashx)->first;
- var_dtor_entries *var_dtor_hash = (*var_hashx)->first_dtor;
- zend_bool wakeup_failed = 0;
- zval wakeup_name;
- ZVAL_UNDEF(&wakeup_name);
-
-#if VAR_ENTRIES_DBG
- fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L);
-#endif
-
- while (var_hash) {
- next = var_hash->next;
- efree_size(var_hash, sizeof(var_entries));
- var_hash = next;
- }
-
- while (var_dtor_hash) {
- for (i = 0; i < var_dtor_hash->used_slots; i++) {
- zval *zv = &var_dtor_hash->data[i];
-#if VAR_ENTRIES_DBG
- fprintf(stderr, "var_destroy dtor(%p, %ld)\n", var_dtor_hash->data[i], Z_REFCOUNT_P(var_dtor_hash->data[i]));
-#endif
-
- /* Perform delayed __wakeup calls */
- if (Z_EXTRA_P(zv) == VAR_WAKEUP_FLAG) {
- if (!wakeup_failed) {
- zval retval;
- if (Z_ISUNDEF(wakeup_name)) {
- ZVAL_STRINGL(&wakeup_name, "__wakeup", sizeof("__wakeup") - 1);
- }
-
- BG(serialize_lock)++;
- if (call_user_function(CG(function_table), zv, &wakeup_name, &retval, 0, 0) == FAILURE || Z_ISUNDEF(retval)) {
- wakeup_failed = 1;
- GC_ADD_FLAGS(Z_OBJ_P(zv), IS_OBJ_DESTRUCTOR_CALLED);
- }
- BG(serialize_lock)--;
-
- zval_ptr_dtor(&retval);
- } else {
- GC_ADD_FLAGS(Z_OBJ_P(zv), IS_OBJ_DESTRUCTOR_CALLED);
- }
- }
-
- i_zval_ptr_dtor(zv);
- }
- next = var_dtor_hash->next;
- efree_size(var_dtor_hash, sizeof(var_dtor_entries));
- var_dtor_hash = next;
- }
-
- zval_ptr_dtor_nogc(&wakeup_name);
-}
-
-/* }}} */
-
-static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t maxlen)
-{
- size_t i, j;
- zend_string *str = zend_string_safe_alloc(1, len, 0, 0);
- unsigned char *end = *(unsigned char **)p+maxlen;
-
- if (end < *p) {
- zend_string_efree(str);
- return NULL;
- }
-
- for (i = 0; i < len; i++) {
- if (*p >= end) {
- zend_string_efree(str);
- return NULL;
- }
- if (**p != '\\') {
- ZSTR_VAL(str)[i] = (char)**p;
- } else {
- unsigned char ch = 0;
-
- for (j = 0; j < 2; j++) {
- (*p)++;
- if (**p >= '0' && **p <= '9') {
- ch = (ch << 4) + (**p -'0');
- } else if (**p >= 'a' && **p <= 'f') {
- ch = (ch << 4) + (**p -'a'+10);
- } else if (**p >= 'A' && **p <= 'F') {
- ch = (ch << 4) + (**p -'A'+10);
- } else {
- zend_string_efree(str);
- return NULL;
- }
- }
- ZSTR_VAL(str)[i] = (char)ch;
- }
- (*p)++;
- }
- ZSTR_VAL(str)[i] = 0;
- ZSTR_LEN(str) = i;
- return str;
-}
-
-static inline int unserialize_allowed_class(
- zend_string *class_name, php_unserialize_data_t *var_hashx)
-{
- HashTable *classes = (*var_hashx)->allowed_classes;
- zend_string *lcname;
- int res;
- ALLOCA_FLAG(use_heap)
-
- if(classes == NULL) {
- return 1;
- }
- if(!zend_hash_num_elements(classes)) {
- return 0;
- }
-
- ZSTR_ALLOCA_ALLOC(lcname, ZSTR_LEN(class_name), use_heap);
- zend_str_tolower_copy(ZSTR_VAL(lcname), ZSTR_VAL(class_name), ZSTR_LEN(class_name));
- res = zend_hash_exists(classes, lcname);
- ZSTR_ALLOCA_FREE(lcname, use_heap);
- return res;
-}
-
-#define YYFILL(n) do { } while (0)
-#define YYCTYPE unsigned char
-#define YYCURSOR cursor
-#define YYLIMIT limit
-#define YYMARKER marker
-
-
-#line 323 "ext/standard/var_unserializer.re"
-
-
-
-
-static inline zend_long parse_iv2(const unsigned char *p, const unsigned char **q)
-{
- zend_ulong result = 0;
- zend_ulong neg = 0;
- const unsigned char *start;
-
- if (*p == '-') {
- neg = 1;
- p++;
- } else if (UNEXPECTED(*p == '+')) {
- p++;
- }
-
- while (UNEXPECTED(*p == '0')) {
- p++;
- }
-
- start = p;
-
- while (*p >= '0' && *p <= '9') {
- result = result * 10 + ((zend_ulong)(*p) - '0');
- p++;
- }
-
- if (q) {
- *q = p;
- }
-
- /* number too long or overflow */
- if (UNEXPECTED(p - start > MAX_LENGTH_OF_LONG - 1)
- || (SIZEOF_ZEND_LONG == 4
- && UNEXPECTED(p - start == MAX_LENGTH_OF_LONG - 1)
- && UNEXPECTED(*start > '2'))
- || UNEXPECTED(result - neg > ZEND_LONG_MAX)) {
- php_error_docref(NULL, E_WARNING, "Numerical result out of range");
- return (!neg) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
- }
-
- return (!neg) ? (zend_long)result : -(zend_long)result;
-}
-
-static inline zend_long parse_iv(const unsigned char *p)
-{
- return parse_iv2(p, NULL);
-}
-
-/* no need to check for length - re2c already did */
-static inline size_t parse_uiv(const unsigned char *p)
-{
- unsigned char cursor;
- size_t result = 0;
-
- while (1) {
- cursor = *p;
- if (cursor >= '0' && cursor <= '9') {
- result = result * 10 + (size_t)(cursor - (unsigned char)'0');
- } else {
- break;
- }
- p++;
- }
- return result;
-}
-
-#define UNSERIALIZE_PARAMETER zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash
-#define UNSERIALIZE_PASSTHRU rval, p, max, var_hash
-
-static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER, int as_key);
-
-static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops)
-{
- while (elements-- > 0) {
- zval key, *data, d, *old_data;
- zend_ulong idx;
-
- ZVAL_UNDEF(&key);
-
- if (!php_var_unserialize_internal(&key, p, max, NULL, 1)) {
- zval_ptr_dtor(&key);
- return 0;
- }
-
- data = NULL;
- ZVAL_UNDEF(&d);
-
- if (!objprops) {
- if (Z_TYPE(key) == IS_LONG) {
- idx = Z_LVAL(key);
-numeric_key:
- if (UNEXPECTED((old_data = zend_hash_index_find(ht, idx)) != NULL)) {
- //??? update hash
- var_push_dtor(var_hash, old_data);
- data = zend_hash_index_update(ht, idx, &d);
- } else {
- data = zend_hash_index_add_new(ht, idx, &d);
- }
- } else if (Z_TYPE(key) == IS_STRING) {
- if (UNEXPECTED(ZEND_HANDLE_NUMERIC(Z_STR(key), idx))) {
- goto numeric_key;
- }
- if (UNEXPECTED((old_data = zend_hash_find(ht, Z_STR(key))) != NULL)) {
- //??? update hash
- var_push_dtor(var_hash, old_data);
- data = zend_hash_update(ht, Z_STR(key), &d);
- } else {
- data = zend_hash_add_new(ht, Z_STR(key), &d);
- }
- } else {
- zval_ptr_dtor(&key);
- return 0;
- }
- } else {
- if (EXPECTED(Z_TYPE(key) == IS_STRING)) {
-string_key:
- if (Z_TYPE_P(rval) == IS_OBJECT
- && zend_hash_num_elements(&Z_OBJCE_P(rval)->properties_info) > 0) {
- zend_property_info *existing_propinfo;
- zend_string *new_key;
- const char *unmangled_class = NULL;
- const char *unmangled_prop;
- size_t unmangled_prop_len;
- zend_string *unmangled;
-
- if (UNEXPECTED(zend_unmangle_property_name_ex(Z_STR(key), &unmangled_class, &unmangled_prop, &unmangled_prop_len) == FAILURE)) {
- zval_ptr_dtor(&key);
- return 0;
- }
-
- unmangled = zend_string_init(unmangled_prop, unmangled_prop_len, 0);
-
- existing_propinfo = zend_hash_find_ptr(&Z_OBJCE_P(rval)->properties_info, unmangled);
- if ((unmangled_class == NULL || !strcmp(unmangled_class, "*") || !strcasecmp(unmangled_class, ZSTR_VAL(Z_OBJCE_P(rval)->name)))
- && (existing_propinfo != NULL)
- && (existing_propinfo->flags & ZEND_ACC_PPP_MASK)) {
- if (existing_propinfo->flags & ZEND_ACC_PROTECTED) {
- new_key = zend_mangle_property_name(
- "*", 1, ZSTR_VAL(unmangled), ZSTR_LEN(unmangled), 0);
- zend_string_release_ex(unmangled, 0);
- } else if (existing_propinfo->flags & ZEND_ACC_PRIVATE) {
- if (unmangled_class != NULL && strcmp(unmangled_class, "*") != 0) {
- new_key = zend_mangle_property_name(
- unmangled_class, strlen(unmangled_class),
- ZSTR_VAL(unmangled), ZSTR_LEN(unmangled),
- 0);
- } else {
- new_key = zend_mangle_property_name(
- ZSTR_VAL(existing_propinfo->ce->name), ZSTR_LEN(existing_propinfo->ce->name),
- ZSTR_VAL(unmangled), ZSTR_LEN(unmangled),
- 0);
- }
- zend_string_release_ex(unmangled, 0);
- } else {
- ZEND_ASSERT(existing_propinfo->flags & ZEND_ACC_PUBLIC);
- new_key = unmangled;
- }
- zval_ptr_dtor_str(&key);
- ZVAL_STR(&key, new_key);
- } else {
- zend_string_release_ex(unmangled, 0);
- }
- }
-
- if ((old_data = zend_hash_find(ht, Z_STR(key))) != NULL) {
- if (Z_TYPE_P(old_data) == IS_INDIRECT) {
- old_data = Z_INDIRECT_P(old_data);
- }
- var_push_dtor(var_hash, old_data);
- data = zend_hash_update_ind(ht, Z_STR(key), &d);
- } else {
- data = zend_hash_add_new(ht, Z_STR(key), &d);
- }
- } else if (Z_TYPE(key) == IS_LONG) {
- /* object properties should include no integers */
- convert_to_string(&key);
- goto string_key;
- } else {
- zval_ptr_dtor(&key);
- return 0;
- }
- }
-
- if (!php_var_unserialize_internal(data, p, max, var_hash, 0)) {
- zval_ptr_dtor(&key);
- return 0;
- }
-
- var_push_dtor(var_hash, data);
- zval_ptr_dtor_str(&key);
-
- if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
- (*p)--;
- return 0;
- }
- }
-
- return 1;
-}
-
-static inline int finish_nested_data(UNSERIALIZE_PARAMETER)
-{
- if (*p >= max || **p != '}') {
- return 0;
- }
-
- (*p)++;
- return 1;
-}
-
-static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
-{
- zend_long datalen;
-
- datalen = parse_iv2((*p) + 2, p);
-
- (*p) += 2;
-
- if (datalen < 0 || (max - (*p)) <= datalen) {
- zend_error(E_WARNING, "Insufficient data for unserializing - " ZEND_LONG_FMT " required, " ZEND_LONG_FMT " present", datalen, (zend_long)(max - (*p)));
- return 0;
- }
-
- /* Check that '}' is present before calling ce->unserialize() to mitigate issues
- * with unserialize reading past the end of the passed buffer if the string is not
- * appropriately terminated (usually NUL terminated, but '}' is also sufficient.) */
- if ((*p)[datalen] != '}') {
- return 0;
- }
-
- if (ce->unserialize == NULL) {
- zend_error(E_WARNING, "Class %s has no unserializer", ZSTR_VAL(ce->name));
- object_init_ex(rval, ce);
- } else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash) != SUCCESS) {
- return 0;
- }
-
- (*p) += datalen + 1; /* +1 for '}' */
- return 1;
-}
-
-static inline zend_long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
-{
- zend_long elements;
-
- if( *p >= max - 2) {
- zend_error(E_WARNING, "Bad unserialize data");
- return -1;
- }
-
- elements = parse_iv2((*p) + 2, p);
-
- (*p) += 2;
-
- if (ce->serialize == NULL) {
- object_init_ex(rval, ce);
- } else {
- /* If this class implements Serializable, it should not land here but in object_custom(). The passed string
- obviously doesn't descend from the regular serializer. */
- zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ZSTR_VAL(ce->name));
- return -1;
- }
-
- return elements;
-}
-
-#ifdef PHP_WIN32
-# pragma optimize("", off)
-#endif
-static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
-{
- HashTable *ht;
- zend_bool has_wakeup;
-
- if (Z_TYPE_P(rval) != IS_OBJECT) {
- return 0;
- }
-
- has_wakeup = Z_OBJCE_P(rval) != PHP_IC_ENTRY
- && zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1);
-
- ht = Z_OBJPROP_P(rval);
- if (elements >= (zend_long)(HT_MAX_SIZE - zend_hash_num_elements(ht))) {
- return 0;
- }
-
- zend_hash_extend(ht, zend_hash_num_elements(ht) + elements, HT_FLAGS(ht) & HASH_FLAG_PACKED);
- if (!process_nested_data(UNSERIALIZE_PASSTHRU, ht, elements, 1)) {
- if (has_wakeup) {
- ZVAL_DEREF(rval);
- GC_ADD_FLAGS(Z_OBJ_P(rval), IS_OBJ_DESTRUCTOR_CALLED);
- }
- return 0;
- }
-
- ZVAL_DEREF(rval);
- if (has_wakeup) {
- /* Delay __wakeup call until end of serialization */
- zval *wakeup_var = var_tmp_var(var_hash);
- ZVAL_COPY(wakeup_var, rval);
- Z_EXTRA_P(wakeup_var) = VAR_WAKEUP_FLAG;
- }
-
- return finish_nested_data(UNSERIALIZE_PASSTHRU);
-}
-#ifdef PHP_WIN32
-# pragma optimize("", on)
-#endif
-
-PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
-{
- var_entries *orig_var_entries = (*var_hash)->last;
- zend_long orig_used_slots = orig_var_entries ? orig_var_entries->used_slots : 0;
- int result;
-
- result = php_var_unserialize_internal(UNSERIALIZE_PASSTHRU, 0);
-
- if (!result) {
- /* If the unserialization failed, mark all elements that have been added to var_hash
- * as NULL. This will forbid their use by other unserialize() calls in the same
- * unserialization context. */
- var_entries *e = orig_var_entries;
- zend_long s = orig_used_slots;
- while (e) {
- for (; s < e->used_slots; s++) {
- e->data[s] = NULL;
- }
-
- e = e->next;
- s = 0;
- }
- }
-
- return result;
-}
-
-static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER, int as_key)
-{
- const unsigned char *cursor, *limit, *marker, *start;
- zval *rval_ref;
-
- limit = max;
- cursor = *p;
-
- if (YYCURSOR >= YYLIMIT) {
- return 0;
- }
-
- if (var_hash && (*p)[0] != 'R') {
- var_push(var_hash, rval);
- }
-
- start = cursor;
-
-
-#line 677 "ext/standard/var_unserializer.c"
-{
- YYCTYPE yych;
- static const unsigned char yybm[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 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, 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, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- };
- if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
- yych = *YYCURSOR;
- switch (yych) {
- case 'C':
- case 'O': goto yy4;
- case 'N': goto yy5;
- case 'R': goto yy6;
- case 'S': goto yy7;
- case 'a': goto yy8;
- case 'b': goto yy9;
- case 'd': goto yy10;
- case 'i': goto yy11;
- case 'o': goto yy12;
- case 'r': goto yy13;
- case 's': goto yy14;
- case '}': goto yy15;
- default: goto yy2;
- }
-yy2:
- ++YYCURSOR;
-yy3:
-#line 1076 "ext/standard/var_unserializer.re"
- { return 0; }
-#line 737 "ext/standard/var_unserializer.c"
-yy4:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy17;
- goto yy3;
-yy5:
- yych = *++YYCURSOR;
- if (yych == ';') goto yy19;
- goto yy3;
-yy6:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy21;
- goto yy3;
-yy7:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy22;
- goto yy3;
-yy8:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy23;
- goto yy3;
-yy9:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy24;
- goto yy3;
-yy10:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy25;
- goto yy3;
-yy11:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy26;
- goto yy3;
-yy12:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy27;
- goto yy3;
-yy13:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy28;
- goto yy3;
-yy14:
- yych = *(YYMARKER = ++YYCURSOR);
- if (yych == ':') goto yy29;
- goto yy3;
-yy15:
- ++YYCURSOR;
-#line 1070 "ext/standard/var_unserializer.re"
- {
- /* this is the case where we have less data than planned */
- php_error_docref(NULL, E_NOTICE, "Unexpected end of serialized data");
- return 0; /* not sure if it should be 0 or 1 here? */
-}
-#line 790 "ext/standard/var_unserializer.c"
-yy17:
- yych = *++YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy30;
- }
-yy18:
- YYCURSOR = YYMARKER;
- goto yy3;
-yy19:
- ++YYCURSOR;
-#line 731 "ext/standard/var_unserializer.re"
- {
- *p = YYCURSOR;
- ZVAL_NULL(rval);
- return 1;
-}
-#line 807 "ext/standard/var_unserializer.c"
-yy21:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy32;
- goto yy18;
-yy22:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy34;
- goto yy18;
-yy23:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy36;
- goto yy18;
-yy24:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '0') goto yy38;
- if (yych <= '1') goto yy39;
- goto yy18;
-yy25:
- yych = *++YYCURSOR;
- if (yych <= '/') {
- if (yych <= ',') {
- if (yych == '+') goto yy40;
- goto yy18;
- } else {
- if (yych <= '-') goto yy41;
- if (yych <= '.') goto yy42;
- goto yy18;
- }
- } else {
- if (yych <= 'I') {
- if (yych <= '9') goto yy43;
- if (yych <= 'H') goto yy18;
- goto yy45;
- } else {
- if (yych == 'N') goto yy46;
- goto yy18;
- }
- }
-yy26:
- yych = *++YYCURSOR;
- if (yych <= ',') {
- if (yych == '+') goto yy47;
- goto yy18;
- } else {
- if (yych <= '-') goto yy47;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy48;
- goto yy18;
- }
-yy27:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy50;
- goto yy18;
-yy28:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy52;
- goto yy18;
-yy29:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy54;
- goto yy18;
-yy30:
- ++YYCURSOR;
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yybm[0+yych] & 128) {
- goto yy30;
- }
- if (yych <= '/') goto yy18;
- if (yych <= ':') goto yy56;
- goto yy18;
-yy32:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy32;
- if (yych == ';') goto yy57;
- goto yy18;
-yy34:
- ++YYCURSOR;
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy34;
- if (yych <= ':') goto yy59;
- goto yy18;
-yy36:
- ++YYCURSOR;
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy36;
- if (yych <= ':') goto yy60;
- goto yy18;
-yy38:
- yych = *++YYCURSOR;
- if (yych == ';') goto yy61;
- goto yy18;
-yy39:
- yych = *++YYCURSOR;
- if (yych == ';') goto yy63;
- goto yy18;
-yy40:
- yych = *++YYCURSOR;
- if (yych == '.') goto yy42;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy43;
- goto yy18;
-yy41:
- yych = *++YYCURSOR;
- if (yych <= '/') {
- if (yych != '.') goto yy18;
- } else {
- if (yych <= '9') goto yy43;
- if (yych == 'I') goto yy45;
- goto yy18;
- }
-yy42:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy65;
- goto yy18;
-yy43:
- ++YYCURSOR;
- if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
- yych = *YYCURSOR;
- if (yych <= ':') {
- if (yych <= '.') {
- if (yych <= '-') goto yy18;
- goto yy65;
- } else {
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy43;
- goto yy18;
- }
- } else {
- if (yych <= 'E') {
- if (yych <= ';') goto yy67;
- if (yych <= 'D') goto yy18;
- goto yy69;
- } else {
- if (yych == 'e') goto yy69;
- goto yy18;
- }
- }
-yy45:
- yych = *++YYCURSOR;
- if (yych == 'N') goto yy70;
- goto yy18;
-yy46:
- yych = *++YYCURSOR;
- if (yych == 'A') goto yy71;
- goto yy18;
-yy47:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych >= ':') goto yy18;
-yy48:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy48;
- if (yych == ';') goto yy72;
- goto yy18;
-yy50:
- ++YYCURSOR;
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy50;
- if (yych <= ':') goto yy74;
- goto yy18;
-yy52:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy52;
- if (yych == ';') goto yy75;
- goto yy18;
-yy54:
- ++YYCURSOR;
- if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy54;
- if (yych <= ':') goto yy77;
- goto yy18;
-yy56:
- yych = *++YYCURSOR;
- if (yych == '"') goto yy78;
- goto yy18;
-yy57:
- ++YYCURSOR;
-#line 681 "ext/standard/var_unserializer.re"
- {
- zend_long id;
-
- *p = YYCURSOR;
- if (!var_hash) return 0;
-
- id = parse_uiv(start + 2) - 1;
- if (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) {
- return 0;
- }
-
- if (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) {
- return 0;
- }
-
- if (Z_ISREF_P(rval_ref)) {
- ZVAL_COPY(rval, rval_ref);
- } else {
- ZVAL_NEW_REF(rval_ref, rval_ref);
- ZVAL_COPY(rval, rval_ref);
- }
-
- return 1;
-}
-#line 1036 "ext/standard/var_unserializer.c"
-yy59:
- yych = *++YYCURSOR;
- if (yych == '"') goto yy80;
- goto yy18;
-yy60:
- yych = *++YYCURSOR;
- if (yych == '{') goto yy82;
- goto yy18;
-yy61:
- ++YYCURSOR;
-#line 737 "ext/standard/var_unserializer.re"
- {
- *p = YYCURSOR;
- ZVAL_FALSE(rval);
- return 1;
-}
-#line 1053 "ext/standard/var_unserializer.c"
-yy63:
- ++YYCURSOR;
-#line 743 "ext/standard/var_unserializer.re"
- {
- *p = YYCURSOR;
- ZVAL_TRUE(rval);
- return 1;
-}
-#line 1062 "ext/standard/var_unserializer.c"
-yy65:
- ++YYCURSOR;
- if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
- yych = *YYCURSOR;
- if (yych <= ';') {
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy65;
- if (yych <= ':') goto yy18;
- } else {
- if (yych <= 'E') {
- if (yych <= 'D') goto yy18;
- goto yy69;
- } else {
- if (yych == 'e') goto yy69;
- goto yy18;
- }
- }
-yy67:
- ++YYCURSOR;
-#line 791 "ext/standard/var_unserializer.re"
- {
-#if SIZEOF_ZEND_LONG == 4
-use_double:
-#endif
- *p = YYCURSOR;
- ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));
- return 1;
-}
-#line 1091 "ext/standard/var_unserializer.c"
-yy69:
- yych = *++YYCURSOR;
- if (yych <= ',') {
- if (yych == '+') goto yy84;
- goto yy18;
- } else {
- if (yych <= '-') goto yy84;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy85;
- goto yy18;
- }
-yy70:
- yych = *++YYCURSOR;
- if (yych == 'F') goto yy87;
- goto yy18;
-yy71:
- yych = *++YYCURSOR;
- if (yych == 'N') goto yy87;
- goto yy18;
-yy72:
- ++YYCURSOR;
-#line 749 "ext/standard/var_unserializer.re"
- {
-#if SIZEOF_ZEND_LONG == 4
- int digits = YYCURSOR - start - 3;
-
- if (start[2] == '-' || start[2] == '+') {
- digits--;
- }
-
- /* Use double for large zend_long values that were serialized on a 64-bit system */
- if (digits >= MAX_LENGTH_OF_LONG - 1) {
- if (digits == MAX_LENGTH_OF_LONG - 1) {
- int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1);
-
- if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) {
- goto use_double;
- }
- } else {
- goto use_double;
- }
- }
-#endif
- *p = YYCURSOR;
- ZVAL_LONG(rval, parse_iv(start + 2));
- return 1;
-}
-#line 1139 "ext/standard/var_unserializer.c"
-yy74:
- yych = *++YYCURSOR;
- if (yych == '"') goto yy88;
- goto yy18;
-yy75:
- ++YYCURSOR;
-#line 706 "ext/standard/var_unserializer.re"
- {
- zend_long id;
-
- *p = YYCURSOR;
- if (!var_hash) return 0;
-
- id = parse_uiv(start + 2) - 1;
- if (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) {
- return 0;
- }
-
- if (rval_ref == rval) {
- return 0;
- }
-
- ZVAL_DEREF(rval_ref);
- if (Z_TYPE_P(rval_ref) != IS_OBJECT) {
- return 0;
- }
-
- ZVAL_COPY(rval, rval_ref);
-
- return 1;
-}
-#line 1171 "ext/standard/var_unserializer.c"
-yy77:
- yych = *++YYCURSOR;
- if (yych == '"') goto yy90;
- goto yy18;
-yy78:
- ++YYCURSOR;
-#line 918 "ext/standard/var_unserializer.re"
- {
- size_t len, len2, len3, maxlen;
- zend_long elements;
- char *str;
- zend_string *class_name;
- zend_class_entry *ce;
- int incomplete_class = 0;
-
- int custom_object = 0;
-
- zval user_func;
- zval retval;
- zval args[1];
-
- if (!var_hash) return 0;
- if (*start == 'C') {
- custom_object = 1;
- }
-
- len2 = len = parse_uiv(start + 2);
- maxlen = max - YYCURSOR;
- if (maxlen < len || len == 0) {
- *p = start + 2;
- return 0;
- }
-
- str = (char*)YYCURSOR;
-
- YYCURSOR += len;
-
- if (*(YYCURSOR) != '"') {
- *p = YYCURSOR;
- return 0;
- }
- if (*(YYCURSOR+1) != ':') {
- *p = YYCURSOR+1;
- return 0;
- }
-
- len3 = strspn(str, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\");
- if (len3 != len)
- {
- *p = YYCURSOR + len3 - len;
- return 0;
- }
-
- class_name = zend_string_init(str, len, 0);
-
- do {
- if(!unserialize_allowed_class(class_name, var_hash)) {
- incomplete_class = 1;
- ce = PHP_IC_ENTRY;
- break;
- }
-
- /* Try to find class directly */
- BG(serialize_lock)++;
- ce = zend_lookup_class(class_name);
- if (ce) {
- BG(serialize_lock)--;
- if (EG(exception)) {
- zend_string_release_ex(class_name, 0);
- return 0;
- }
- break;
- }
- BG(serialize_lock)--;
-
- if (EG(exception)) {
- zend_string_release_ex(class_name, 0);
- return 0;
- }
-
- /* Check for unserialize callback */
- if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) {
- incomplete_class = 1;
- ce = PHP_IC_ENTRY;
- break;
- }
-
- /* Call unserialize callback */
- ZVAL_STRING(&user_func, PG(unserialize_callback_func));
-
- ZVAL_STR_COPY(&args[0], class_name);
- BG(serialize_lock)++;
- if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL) != SUCCESS) {
- BG(serialize_lock)--;
- if (EG(exception)) {
- zend_string_release_ex(class_name, 0);
- zval_ptr_dtor(&user_func);
- zval_ptr_dtor(&args[0]);
- return 0;
- }
- php_error_docref(NULL, E_WARNING, "defined (%s) but not found", Z_STRVAL(user_func));
- incomplete_class = 1;
- ce = PHP_IC_ENTRY;
- zval_ptr_dtor(&user_func);
- zval_ptr_dtor(&args[0]);
- break;
- }
- BG(serialize_lock)--;
- zval_ptr_dtor(&retval);
- if (EG(exception)) {
- zend_string_release_ex(class_name, 0);
- zval_ptr_dtor(&user_func);
- zval_ptr_dtor(&args[0]);
- return 0;
- }
-
- /* The callback function may have defined the class */
- BG(serialize_lock)++;
- if ((ce = zend_lookup_class(class_name)) == NULL) {
- php_error_docref(NULL, E_WARNING, "Function %s() hasn't defined the class it was called for", Z_STRVAL(user_func));
- incomplete_class = 1;
- ce = PHP_IC_ENTRY;
- }
- BG(serialize_lock)--;
-
- zval_ptr_dtor(&user_func);
- zval_ptr_dtor(&args[0]);
- break;
- } while (1);
-
- *p = YYCURSOR;
-
- if (custom_object) {
- int ret;
-
- ret = object_custom(UNSERIALIZE_PASSTHRU, ce);
-
- if (ret && incomplete_class) {
- php_store_class_name(rval, ZSTR_VAL(class_name), len2);
- }
- zend_string_release_ex(class_name, 0);
- return ret;
- }
-
- elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
-
- if (elements < 0) {
- zend_string_release_ex(class_name, 0);
- return 0;
- }
-
- if (incomplete_class) {
- php_store_class_name(rval, ZSTR_VAL(class_name), len2);
- }
- zend_string_release_ex(class_name, 0);
-
- return object_common2(UNSERIALIZE_PASSTHRU, elements);
-}
-#line 1330 "ext/standard/var_unserializer.c"
-yy80:
- ++YYCURSOR;
-#line 840 "ext/standard/var_unserializer.re"
- {
- size_t len, maxlen;
- zend_string *str;
-
- len = parse_uiv(start + 2);
- maxlen = max - YYCURSOR;
- if (maxlen < len) {
- *p = start + 2;
- return 0;
- }
-
- if ((str = unserialize_str(&YYCURSOR, len, maxlen)) == NULL) {
- return 0;
- }
-
- if (*(YYCURSOR) != '"') {
- zend_string_efree(str);
- *p = YYCURSOR;
- return 0;
- }
-
- if (*(YYCURSOR + 1) != ';') {
- efree(str);
- *p = YYCURSOR + 1;
- return 0;
- }
-
- YYCURSOR += 2;
- *p = YYCURSOR;
-
- ZVAL_STR(rval, str);
- return 1;
-}
-#line 1367 "ext/standard/var_unserializer.c"
-yy82:
- ++YYCURSOR;
-#line 874 "ext/standard/var_unserializer.re"
- {
- zend_long elements = parse_iv(start + 2);
- /* use iv() not uiv() in order to check data range */
- *p = YYCURSOR;
- if (!var_hash) return 0;
-
- if (elements < 0 || elements >= HT_MAX_SIZE) {
- return 0;
- }
-
- if (elements) {
- array_init_size(rval, elements);
- /* we can't convert from packed to hash during unserialization, because
- reference to some zvals might be keept in var_hash (to support references) */
- zend_hash_real_init_mixed(Z_ARRVAL_P(rval));
- } else {
- ZVAL_EMPTY_ARRAY(rval);
- return finish_nested_data(UNSERIALIZE_PASSTHRU);
- }
-
- /* The array may contain references to itself, in which case we'll be modifying an
- * rc>1 array. This is okay, since the array is, ostensibly, only visible to
- * unserialize (in practice unserialization handlers also see it). Ideally we should
- * prohibit "r:" references to non-objects, as we only generate them for objects. */
- HT_ALLOW_COW_VIOLATION(Z_ARRVAL_P(rval));
-
- if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_P(rval), elements, 0)) {
- return 0;
- }
-
- return finish_nested_data(UNSERIALIZE_PASSTHRU);
-}
-#line 1403 "ext/standard/var_unserializer.c"
-yy84:
- yych = *++YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych >= ':') goto yy18;
-yy85:
- ++YYCURSOR;
- if (YYLIMIT <= YYCURSOR) YYFILL(1);
- yych = *YYCURSOR;
- if (yych <= '/') goto yy18;
- if (yych <= '9') goto yy85;
- if (yych == ';') goto yy67;
- goto yy18;
-yy87:
- yych = *++YYCURSOR;
- if (yych == ';') goto yy92;
- goto yy18;
-yy88:
- ++YYCURSOR;
-#line 907 "ext/standard/var_unserializer.re"
- {
- zend_long elements;
- if (!var_hash) return 0;
-
- elements = object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR);
- if (elements < 0 || elements >= HT_MAX_SIZE) {
- return 0;
- }
- return object_common2(UNSERIALIZE_PASSTHRU, elements);
-}
-#line 1433 "ext/standard/var_unserializer.c"
-yy90:
- ++YYCURSOR;
-#line 800 "ext/standard/var_unserializer.re"
- {
- size_t len, maxlen;
- char *str;
-
- len = parse_uiv(start + 2);
- maxlen = max - YYCURSOR;
- if (maxlen < len) {
- *p = start + 2;
- return 0;
- }
-
- str = (char*)YYCURSOR;
-
- YYCURSOR += len;
-
- if (*(YYCURSOR) != '"') {
- *p = YYCURSOR;
- return 0;
- }
-
- if (*(YYCURSOR + 1) != ';') {
- *p = YYCURSOR + 1;
- return 0;
- }
-
- YYCURSOR += 2;
- *p = YYCURSOR;
-
- if (len == 0) {
- ZVAL_EMPTY_STRING(rval);
- } else if (len == 1) {
- ZVAL_INTERNED_STR(rval, ZSTR_CHAR((zend_uchar)*str));
- } else if (as_key) {
- ZVAL_STR(rval, zend_string_init_interned(str, len, 0));
- } else {
- ZVAL_STRINGL(rval, str, len);
- }
- return 1;
-}
-#line 1476 "ext/standard/var_unserializer.c"
-yy92:
- ++YYCURSOR;
-#line 775 "ext/standard/var_unserializer.re"
- {
- *p = YYCURSOR;
-
- if (!strncmp((char*)start + 2, "NAN", 3)) {
- ZVAL_DOUBLE(rval, ZEND_NAN);
- } else if (!strncmp((char*)start + 2, "INF", 3)) {
- ZVAL_DOUBLE(rval, ZEND_INFINITY);
- } else if (!strncmp((char*)start + 2, "-INF", 4)) {
- ZVAL_DOUBLE(rval, -ZEND_INFINITY);
- } else {
- ZVAL_NULL(rval);
- }
-
- return 1;
-}
-#line 1495 "ext/standard/var_unserializer.c"
-}
-#line 1078 "ext/standard/var_unserializer.re"
-
-
- return 0;
-}