1 /* Generated by re2c 1.0.3 */ 2 #line 1 "ext/phar/phar_path_check.re" 3 /* 4 +----------------------------------------------------------------------+ 5 | phar php single-file executable PHP extension | 6 +----------------------------------------------------------------------+ 7 | Copyright (c) 2007-2018 The PHP Group | 8 +----------------------------------------------------------------------+ 9 | This source file is subject to version 3.01 of the PHP license, | 10 | that is bundled with this package in the file LICENSE, and is | 11 | available through the world-wide-web at the following url: | 12 | http://www.php.net/license/3_01.txt. | 13 | If you did not receive a copy of the PHP license and are unable to | 14 | obtain it through the world-wide-web, please send a note to | 15 | license@php.net so we can mail you a copy immediately. | 16 +----------------------------------------------------------------------+ 17 | Authors: Marcus Boerger <helly@php.net> | 18 +----------------------------------------------------------------------+ 19 */ 20 21 #include "phar_internal.h" 22 phar_path_check(char ** s,size_t * len,const char ** error)23phar_path_check_result phar_path_check(char **s, size_t *len, const char **error) 24 { 25 const unsigned char *p = (const unsigned char*)*s; 26 const unsigned char *m; 27 28 if (*len == 1 && *p == '.') { 29 *error = "current directory reference"; 30 return pcr_err_curr_dir; 31 } else if (*len == 2 && p[0] == '.' && p[1] == '.') { 32 *error = "upper directory reference"; 33 return pcr_err_up_dir; 34 } 35 36 #define YYCTYPE unsigned char 37 #define YYCURSOR p 38 #define YYLIMIT p+*len 39 #define YYMARKER m 40 #define YYFILL(n) 41 42 loop: 43 44 #line 47 "ext/phar/phar_path_check.c" 45 { 46 YYCTYPE yych; 47 unsigned int yyaccept = 0; 48 if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); 49 yych = *YYCURSOR; 50 if (yych <= '[') { 51 if (yych <= ')') { 52 if (yych <= '\f') { 53 if (yych >= 0x01) goto yy4; 54 } else { 55 if (yych <= '\r') goto yy6; 56 if (yych <= 0x19) goto yy4; 57 goto yy7; 58 } 59 } else { 60 if (yych <= '/') { 61 if (yych <= '*') goto yy9; 62 if (yych <= '.') goto yy7; 63 goto yy11; 64 } else { 65 if (yych == '?') goto yy12; 66 goto yy7; 67 } 68 } 69 } else { 70 if (yych <= 0xEC) { 71 if (yych <= 0xC1) { 72 if (yych <= '\\') goto yy14; 73 if (yych <= 0x7F) goto yy7; 74 goto yy4; 75 } else { 76 if (yych <= 0xDF) goto yy16; 77 if (yych <= 0xE0) goto yy17; 78 goto yy18; 79 } 80 } else { 81 if (yych <= 0xF0) { 82 if (yych <= 0xED) goto yy19; 83 if (yych <= 0xEF) goto yy18; 84 goto yy20; 85 } else { 86 if (yych <= 0xF3) goto yy21; 87 if (yych <= 0xF4) goto yy22; 88 goto yy4; 89 } 90 } 91 } 92 ++YYCURSOR; 93 #line 93 "ext/phar/phar_path_check.re" 94 { 95 if (**s == '/') { 96 (*s)++; 97 (*len)--; 98 } 99 if ((p - (const unsigned char*)*s) - 1 != *len) 100 { 101 *error ="illegal character"; 102 return pcr_err_illegal_char; 103 } 104 *error = NULL; 105 return pcr_is_ok; 106 } 107 #line 110 "ext/phar/phar_path_check.c" 108 yy4: 109 ++YYCURSOR; 110 yy5: 111 #line 106 "ext/phar/phar_path_check.re" 112 { 113 *error ="illegal character"; 114 return pcr_err_illegal_char; 115 } 116 #line 119 "ext/phar/phar_path_check.c" 117 yy6: 118 yych = *++YYCURSOR; 119 if (yych == '\n') goto yy4; 120 goto yy5; 121 yy7: 122 ++YYCURSOR; 123 yy8: 124 #line 90 "ext/phar/phar_path_check.re" 125 { 126 goto loop; 127 } 128 #line 131 "ext/phar/phar_path_check.c" 129 yy9: 130 ++YYCURSOR; 131 #line 78 "ext/phar/phar_path_check.re" 132 { 133 *error = "star"; 134 return pcr_err_star; 135 } 136 #line 139 "ext/phar/phar_path_check.c" 137 yy11: 138 yyaccept = 0; 139 yych = *(YYMARKER = ++YYCURSOR); 140 if (yych <= '-') goto yy8; 141 if (yych <= '.') goto yy23; 142 if (yych <= '/') goto yy25; 143 goto yy8; 144 yy12: 145 ++YYCURSOR; 146 #line 82 "ext/phar/phar_path_check.re" 147 { 148 if (**s == '/') { 149 (*s)++; 150 } 151 *len = (p - (const unsigned char*)*s) -1; 152 *error = NULL; 153 return pcr_use_query; 154 } 155 #line 158 "ext/phar/phar_path_check.c" 156 yy14: 157 ++YYCURSOR; 158 #line 74 "ext/phar/phar_path_check.re" 159 { 160 *error = "back-slash"; 161 return pcr_err_back_slash; 162 } 163 #line 166 "ext/phar/phar_path_check.c" 164 yy16: 165 yych = *++YYCURSOR; 166 if (yych <= 0x7F) goto yy5; 167 if (yych <= 0xBF) goto yy7; 168 goto yy5; 169 yy17: 170 yyaccept = 1; 171 yych = *(YYMARKER = ++YYCURSOR); 172 if (yych <= 0x9F) goto yy5; 173 if (yych <= 0xBF) goto yy27; 174 goto yy5; 175 yy18: 176 yyaccept = 1; 177 yych = *(YYMARKER = ++YYCURSOR); 178 if (yych <= 0x7F) goto yy5; 179 if (yych <= 0xBF) goto yy27; 180 goto yy5; 181 yy19: 182 yyaccept = 1; 183 yych = *(YYMARKER = ++YYCURSOR); 184 if (yych <= 0x7F) goto yy5; 185 if (yych <= 0x9F) goto yy27; 186 goto yy5; 187 yy20: 188 yyaccept = 1; 189 yych = *(YYMARKER = ++YYCURSOR); 190 if (yych <= 0x8F) goto yy5; 191 if (yych <= 0xBF) goto yy28; 192 goto yy5; 193 yy21: 194 yyaccept = 1; 195 yych = *(YYMARKER = ++YYCURSOR); 196 if (yych <= 0x7F) goto yy5; 197 if (yych <= 0xBF) goto yy28; 198 goto yy5; 199 yy22: 200 yyaccept = 1; 201 yych = *(YYMARKER = ++YYCURSOR); 202 if (yych <= 0x7F) goto yy5; 203 if (yych <= 0x8F) goto yy28; 204 goto yy5; 205 yy23: 206 yych = *++YYCURSOR; 207 if (yych <= 0x00) goto yy29; 208 if (yych <= '-') goto yy24; 209 if (yych <= '.') goto yy31; 210 if (yych <= '/') goto yy29; 211 yy24: 212 YYCURSOR = YYMARKER; 213 if (yyaccept == 0) { 214 goto yy8; 215 } else { 216 goto yy5; 217 } 218 yy25: 219 ++YYCURSOR; 220 #line 62 "ext/phar/phar_path_check.re" 221 { 222 *error = "double slash"; 223 return pcr_err_double_slash; 224 } 225 #line 228 "ext/phar/phar_path_check.c" 226 yy27: 227 yych = *++YYCURSOR; 228 if (yych <= 0x7F) goto yy24; 229 if (yych <= 0xBF) goto yy7; 230 goto yy24; 231 yy28: 232 yych = *++YYCURSOR; 233 if (yych <= 0x7F) goto yy24; 234 if (yych <= 0xBF) goto yy27; 235 goto yy24; 236 yy29: 237 ++YYCURSOR; 238 #line 70 "ext/phar/phar_path_check.re" 239 { 240 *error = "current directory reference"; 241 return pcr_err_curr_dir; 242 } 243 #line 246 "ext/phar/phar_path_check.c" 244 yy31: 245 yych = *++YYCURSOR; 246 if (yych <= 0x00) goto yy32; 247 if (yych != '/') goto yy24; 248 yy32: 249 ++YYCURSOR; 250 #line 66 "ext/phar/phar_path_check.re" 251 { 252 *error = "upper directory reference"; 253 return pcr_err_up_dir; 254 } 255 #line 258 "ext/phar/phar_path_check.c" 256 } 257 #line 110 "ext/phar/phar_path_check.re" 258 259 } 260