1 : /* Generated by re2c 0.12.3 on Tue Jan 8 18:41:21 2008 */
2 : #line 1 "ext/phar/phar_path_check.re"
3 : /*
4 : +----------------------------------------------------------------------+
5 : | phar php single-file executable PHP extension |
6 : +----------------------------------------------------------------------+
7 : | Copyright (c) 2007-2009 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: phar_path_check.c 272370 2008-12-31 11:15:49Z sebastian $ */
22 :
23 : #include "phar_internal.h"
24 :
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 :
47 : #line 48 "ext/phar/phar_path_check.c"
48 : {
49 : YYCTYPE yych;
50 :
51 247876 : if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
52 247876 : yych = *YYCURSOR;
53 247876 : if(yych <= '.') {
54 13799 : if(yych <= 0x0A) {
55 12379 : if(yych <= 0x00) goto yy13;
56 0 : if(yych <= 0x09) goto yy10;
57 0 : goto yy12;
58 : } else {
59 1420 : if(yych <= 0x19) goto yy10;
60 1420 : if(yych == '*') goto yy6;
61 1420 : goto yy15;
62 : }
63 : } else {
64 234077 : if(yych <= '?') {
65 56442 : if(yych <= '/') goto yy2;
66 30766 : if(yych <= '>') goto yy15;
67 4 : goto yy8;
68 : } else {
69 177635 : if(yych == '\\') goto yy4;
70 177635 : if(yych <= 0x7F) goto yy15;
71 0 : goto yy10;
72 : }
73 : }
74 25676 : yy2:
75 25676 : yych = *(YYMARKER = ++YYCURSOR);
76 25676 : if(yych <= '-') goto yy3;
77 25669 : if(yych <= '.') goto yy16;
78 25662 : if(yych <= '/') goto yy18;
79 235486 : yy3:
80 : #line 93 "ext/phar/phar_path_check.re"
81 : {
82 : goto loop;
83 : }
84 : #line 85 "ext/phar/phar_path_check.c"
85 0 : yy4:
86 0 : ++YYCURSOR;
87 : #line 60 "ext/phar/phar_path_check.re"
88 : {
89 : *error = "back-slash";
90 : return pcr_err_back_slash;
91 : }
92 : #line 93 "ext/phar/phar_path_check.c"
93 0 : yy6:
94 0 : ++YYCURSOR;
95 : #line 64 "ext/phar/phar_path_check.re"
96 : {
97 : *error = "star";
98 : return pcr_err_star;
99 : }
100 : #line 101 "ext/phar/phar_path_check.c"
101 4 : yy8:
102 4 : ++YYCURSOR;
103 : #line 68 "ext/phar/phar_path_check.re"
104 : {
105 : if (**s == '/') {
106 : (*s)++;
107 : }
108 : *len = (p - (const unsigned char*)*s) -1;
109 : *error = NULL;
110 : return pcr_use_query;
111 : }
112 : #line 113 "ext/phar/phar_path_check.c"
113 0 : yy10:
114 0 : ++YYCURSOR;
115 0 : yy11:
116 : #line 76 "ext/phar/phar_path_check.re"
117 : {
118 : *error ="illegal character";
119 : return pcr_err_illegal_char;
120 : }
121 : #line 122 "ext/phar/phar_path_check.c"
122 0 : yy12:
123 0 : yych = *++YYCURSOR;
124 0 : goto yy11;
125 12379 : yy13:
126 12379 : ++YYCURSOR;
127 : #line 80 "ext/phar/phar_path_check.re"
128 : {
129 : if (**s == '/') {
130 : (*s)++;
131 : (*len)--;
132 : }
133 : if ((p - (const unsigned char*)*s) - 1 != *len)
134 : {
135 : *error ="illegal character";
136 : return pcr_err_illegal_char;
137 : }
138 : *error = NULL;
139 : return pcr_is_ok;
140 : }
141 : #line 142 "ext/phar/phar_path_check.c"
142 209817 : yy15:
143 209817 : yych = *++YYCURSOR;
144 209817 : goto yy3;
145 7 : yy16:
146 7 : yych = *++YYCURSOR;
147 7 : if(yych <= 0x00) goto yy21;
148 7 : if(yych <= '-') goto yy17;
149 7 : if(yych <= '.') goto yy20;
150 2 : if(yych <= '/') goto yy21;
151 2 : yy17:
152 2 : YYCURSOR = YYMARKER;
153 2 : goto yy3;
154 2 : yy18:
155 2 : ++YYCURSOR;
156 : #line 48 "ext/phar/phar_path_check.re"
157 : {
158 : *error = "double slash";
159 : return pcr_err_double_slash;
160 : }
161 : #line 162 "ext/phar/phar_path_check.c"
162 5 : yy20:
163 5 : yych = *++YYCURSOR;
164 5 : if(yych <= 0x00) goto yy23;
165 0 : if(yych == '/') goto yy23;
166 0 : goto yy17;
167 0 : yy21:
168 0 : ++YYCURSOR;
169 : #line 56 "ext/phar/phar_path_check.re"
170 : {
171 : *error = "current directory reference";
172 : return pcr_err_curr_dir;
173 : }
174 : #line 175 "ext/phar/phar_path_check.c"
175 5 : yy23:
176 5 : ++YYCURSOR;
177 : #line 52 "ext/phar/phar_path_check.re"
178 : {
179 : *error = "upper directory reference";
180 : return pcr_err_up_dir;
181 : }
182 : #line 183 "ext/phar/phar_path_check.c"
183 : }
184 : }
185 : #line 96 "ext/phar/phar_path_check.re"
186 :
187 : }
|