xref: /PHP-5.4/ext/phar/phar_path_check.c (revision 61499bf2)
1 /* Generated by re2c 0.13.5 on Tue Apr 22 16:55:12 2014 */
2 #line 1 "ext/phar/phar_path_check.re"
3 /*
4   +----------------------------------------------------------------------+
5   | phar php single-file executable PHP extension                        |
6   +----------------------------------------------------------------------+
7   | Copyright (c) 2007-2014 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 /* $Id$ */
22 
23 #include "phar_internal.h"
24 
phar_path_check(char ** s,int * len,const char ** error)25 phar_path_check_result phar_path_check(char **s, int *len, const char **error)
26 {
27 	const unsigned char *p = (const unsigned char*)*s;
28 	const unsigned char *m;
29 
30 	if (*len == 1 && *p == '.') {
31 		*error = "current directory reference";
32 		return pcr_err_curr_dir;
33 	} else if (*len == 2 && p[0] == '.' && p[1] == '.') {
34 		*error = "upper directory reference";
35 		return pcr_err_up_dir;
36 	}
37 
38 #define YYCTYPE         unsigned char
39 #define YYCURSOR        p
40 #define YYLIMIT         p+*len
41 #define YYMARKER        m
42 #define YYFILL(n)
43 
44 loop:
45 
46 #line 47 "ext/phar/phar_path_check.c"
47 {
48 	YYCTYPE yych;
49 	unsigned int yyaccept = 0;
50 
51 	if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
52 	yych = *YYCURSOR;
53 	if (yych <= '[') {
54 		if (yych <= ')') {
55 			if (yych <= '\t') {
56 				if (yych <= 0x00) goto yy21;
57 				goto yy23;
58 			} else {
59 				if (yych <= '\n') goto yy2;
60 				if (yych <= 0x19) goto yy23;
61 				goto yy11;
62 			}
63 		} else {
64 			if (yych <= '/') {
65 				if (yych <= '*') goto yy7;
66 				if (yych <= '.') goto yy11;
67 				goto yy3;
68 			} else {
69 				if (yych == '?') goto yy9;
70 				goto yy11;
71 			}
72 		}
73 	} else {
74 		if (yych <= 0xEC) {
75 			if (yych <= 0xC1) {
76 				if (yych <= '\\') goto yy5;
77 				if (yych <= 0x7F) goto yy11;
78 				goto yy23;
79 			} else {
80 				if (yych <= 0xDF) goto yy12;
81 				if (yych <= 0xE0) goto yy14;
82 				goto yy15;
83 			}
84 		} else {
85 			if (yych <= 0xF0) {
86 				if (yych <= 0xED) goto yy16;
87 				if (yych <= 0xEF) goto yy17;
88 				goto yy18;
89 			} else {
90 				if (yych <= 0xF3) goto yy19;
91 				if (yych <= 0xF4) goto yy20;
92 				goto yy23;
93 			}
94 		}
95 	}
96 yy2:
97 	YYCURSOR = YYMARKER;
98 	if (yyaccept <= 0) {
99 		goto yy4;
100 	} else {
101 		goto yy13;
102 	}
103 yy3:
104 	yyaccept = 0;
105 	yych = *(YYMARKER = ++YYCURSOR);
106 	if (yych <= '-') goto yy4;
107 	if (yych <= '.') goto yy35;
108 	if (yych <= '/') goto yy36;
109 yy4:
110 #line 88 "ext/phar/phar_path_check.re"
111 	{
112 			goto loop;
113 		}
114 #line 115 "ext/phar/phar_path_check.c"
115 yy5:
116 	++YYCURSOR;
117 #line 72 "ext/phar/phar_path_check.re"
118 	{
119 			*error = "back-slash";
120 			return pcr_err_back_slash;
121 		}
122 #line 123 "ext/phar/phar_path_check.c"
123 yy7:
124 	++YYCURSOR;
125 #line 76 "ext/phar/phar_path_check.re"
126 	{
127 			*error = "star";
128 			return pcr_err_star;
129 		}
130 #line 131 "ext/phar/phar_path_check.c"
131 yy9:
132 	++YYCURSOR;
133 #line 80 "ext/phar/phar_path_check.re"
134 	{
135 			if (**s == '/') {
136 				(*s)++;
137 			}
138 			*len = (p - (const unsigned char*)*s) -1;
139 			*error = NULL;
140 			return pcr_use_query;
141 		}
142 #line 143 "ext/phar/phar_path_check.c"
143 yy11:
144 	yych = *++YYCURSOR;
145 	goto yy4;
146 yy12:
147 	++YYCURSOR;
148 	if ((yych = *YYCURSOR) <= 0x7F) goto yy13;
149 	if (yych <= 0xBF) goto yy26;
150 yy13:
151 #line 104 "ext/phar/phar_path_check.re"
152 	{
153 			*error ="illegal character";
154 			return pcr_err_illegal_char;
155 		}
156 #line 157 "ext/phar/phar_path_check.c"
157 yy14:
158 	yyaccept = 1;
159 	yych = *(YYMARKER = ++YYCURSOR);
160 	if (yych <= 0x9F) goto yy13;
161 	if (yych <= 0xBF) goto yy34;
162 	goto yy13;
163 yy15:
164 	yyaccept = 1;
165 	yych = *(YYMARKER = ++YYCURSOR);
166 	if (yych <= 0x7F) goto yy13;
167 	if (yych <= 0xBF) goto yy33;
168 	goto yy13;
169 yy16:
170 	yyaccept = 1;
171 	yych = *(YYMARKER = ++YYCURSOR);
172 	if (yych <= 0x7F) goto yy13;
173 	if (yych <= 0x9F) goto yy32;
174 	goto yy13;
175 yy17:
176 	yyaccept = 1;
177 	yych = *(YYMARKER = ++YYCURSOR);
178 	if (yych <= 0x7F) goto yy13;
179 	if (yych <= 0xBF) goto yy31;
180 	goto yy13;
181 yy18:
182 	yyaccept = 1;
183 	yych = *(YYMARKER = ++YYCURSOR);
184 	if (yych <= 0x8F) goto yy13;
185 	if (yych <= 0xBF) goto yy29;
186 	goto yy13;
187 yy19:
188 	yyaccept = 1;
189 	yych = *(YYMARKER = ++YYCURSOR);
190 	if (yych <= 0x7F) goto yy13;
191 	if (yych <= 0xBF) goto yy27;
192 	goto yy13;
193 yy20:
194 	yyaccept = 1;
195 	yych = *(YYMARKER = ++YYCURSOR);
196 	if (yych <= 0x7F) goto yy13;
197 	if (yych <= 0x8F) goto yy24;
198 	goto yy13;
199 yy21:
200 	++YYCURSOR;
201 #line 91 "ext/phar/phar_path_check.re"
202 	{
203 			if (**s == '/') {
204 				(*s)++;
205 				(*len)--;
206 			}
207 			if ((p - (const unsigned char*)*s) - 1 != *len)
208 			{
209 				*error ="illegal character";
210 				return pcr_err_illegal_char;
211 			}
212 			*error = NULL;
213 			return pcr_is_ok;
214 		}
215 #line 216 "ext/phar/phar_path_check.c"
216 yy23:
217 	yych = *++YYCURSOR;
218 	goto yy13;
219 yy24:
220 	yych = *++YYCURSOR;
221 	if (yych <= 0x7F) goto yy2;
222 	if (yych >= 0xC0) goto yy2;
223 	yych = *++YYCURSOR;
224 	if (yych <= 0x7F) goto yy2;
225 	if (yych >= 0xC0) goto yy2;
226 yy26:
227 	yych = *++YYCURSOR;
228 	goto yy4;
229 yy27:
230 	yych = *++YYCURSOR;
231 	if (yych <= 0x7F) goto yy2;
232 	if (yych >= 0xC0) goto yy2;
233 	yych = *++YYCURSOR;
234 	if (yych <= 0x7F) goto yy2;
235 	if (yych <= 0xBF) goto yy26;
236 	goto yy2;
237 yy29:
238 	yych = *++YYCURSOR;
239 	if (yych <= 0x7F) goto yy2;
240 	if (yych >= 0xC0) goto yy2;
241 	yych = *++YYCURSOR;
242 	if (yych <= 0x7F) goto yy2;
243 	if (yych <= 0xBF) goto yy26;
244 	goto yy2;
245 yy31:
246 	yych = *++YYCURSOR;
247 	if (yych <= 0x7F) goto yy2;
248 	if (yych <= 0xBF) goto yy26;
249 	goto yy2;
250 yy32:
251 	yych = *++YYCURSOR;
252 	if (yych <= 0x7F) goto yy2;
253 	if (yych <= 0xBF) goto yy26;
254 	goto yy2;
255 yy33:
256 	yych = *++YYCURSOR;
257 	if (yych <= 0x7F) goto yy2;
258 	if (yych <= 0xBF) goto yy26;
259 	goto yy2;
260 yy34:
261 	yych = *++YYCURSOR;
262 	if (yych <= 0x7F) goto yy2;
263 	if (yych <= 0xBF) goto yy26;
264 	goto yy2;
265 yy35:
266 	yych = *++YYCURSOR;
267 	if (yych <= 0x00) goto yy39;
268 	if (yych <= '-') goto yy2;
269 	if (yych <= '.') goto yy38;
270 	if (yych <= '/') goto yy39;
271 	goto yy2;
272 yy36:
273 	++YYCURSOR;
274 #line 60 "ext/phar/phar_path_check.re"
275 	{
276 			*error = "double slash";
277 			return pcr_err_double_slash;
278 		}
279 #line 280 "ext/phar/phar_path_check.c"
280 yy38:
281 	yych = *++YYCURSOR;
282 	if (yych <= 0x00) goto yy41;
283 	if (yych == '/') goto yy41;
284 	goto yy2;
285 yy39:
286 	++YYCURSOR;
287 #line 68 "ext/phar/phar_path_check.re"
288 	{
289 			*error = "current directory reference";
290 			return pcr_err_curr_dir;
291 		}
292 #line 293 "ext/phar/phar_path_check.c"
293 yy41:
294 	++YYCURSOR;
295 #line 64 "ext/phar/phar_path_check.re"
296 	{
297 			*error = "upper directory reference";
298 			return pcr_err_up_dir;
299 		}
300 #line 301 "ext/phar/phar_path_check.c"
301 }
302 #line 108 "ext/phar/phar_path_check.re"
303 
304 }
305