2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
15 #ifdef PHP_HTTP_HAVE_IDN
19 #ifdef PHP_HTTP_HAVE_WCHAR
24 #ifdef HAVE_ARPA_INET_H
25 # include <arpa/inet.h>
28 #include "php_http_utf8.h"
30 static inline char *localhostname(void)
32 char hostname
[1024] = {0};
35 if (SUCCESS
== gethostname(hostname
, lenof(hostname
))) {
36 return estrdup(hostname
);
38 #elif defined(HAVE_GETHOSTNAME)
39 if (SUCCESS
== gethostname(hostname
, lenof(hostname
))) {
40 # if defined(HAVE_GETDOMAINNAME)
41 size_t hlen
= strlen(hostname
);
42 if (hlen
<= lenof(hostname
) - lenof("(none)")) {
43 hostname
[hlen
++] = '.';
44 if (SUCCESS
== getdomainname(&hostname
[hlen
], lenof(hostname
) - hlen
)) {
45 if (!strcmp(&hostname
[hlen
], "(none)")) {
46 hostname
[hlen
- 1] = '\0';
48 return estrdup(hostname
);
52 if (strcmp(hostname
, "(none)")) {
53 return estrdup(hostname
);
57 return estrndup("localhost", lenof("localhost"));
60 #define url(buf) ((php_http_url_t *) buf.data)
62 static php_http_url_t
*php_http_url_from_env(void)
64 zval
*https
, *zhost
, *zport
;
66 php_http_buffer_t buf
;
68 php_http_buffer_init_ex(&buf
, MAX(PHP_HTTP_BUFFER_DEFAULT_SIZE
, sizeof(php_http_url_t
)<<2), PHP_HTTP_BUFFER_INIT_PREALLOC
);
69 php_http_buffer_account(&buf
, sizeof(php_http_url_t
));
70 memset(buf
.data
, 0, buf
.used
);
73 url(buf
)->scheme
= &buf
.data
[buf
.used
];
74 https
= php_http_env_get_server_var(ZEND_STRL("HTTPS"), 1);
75 if (https
&& !strcasecmp(Z_STRVAL_P(https
), "ON")) {
76 php_http_buffer_append(&buf
, "https", sizeof("https"));
78 php_http_buffer_append(&buf
, "http", sizeof("http"));
82 url(buf
)->host
= &buf
.data
[buf
.used
];
83 if ((((zhost
= php_http_env_get_server_var(ZEND_STRL("HTTP_HOST"), 1)) ||
84 (zhost
= php_http_env_get_server_var(ZEND_STRL("SERVER_NAME"), 1)) ||
85 (zhost
= php_http_env_get_server_var(ZEND_STRL("SERVER_ADDR"), 1)))) && Z_STRLEN_P(zhost
)) {
86 size_t stop_at
= strspn(Z_STRVAL_P(zhost
), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-.");
88 php_http_buffer_append(&buf
, Z_STRVAL_P(zhost
), stop_at
);
89 php_http_buffer_append(&buf
, "", 1);
91 char *host_str
= localhostname();
93 php_http_buffer_append(&buf
, host_str
, strlen(host_str
) + 1);
98 zport
= php_http_env_get_server_var(ZEND_STRL("SERVER_PORT"), 1);
99 if (zport
&& IS_LONG
== is_numeric_string(Z_STRVAL_P(zport
), Z_STRLEN_P(zport
), &port
, NULL
, 0)) {
100 url(buf
)->port
= port
;
104 if (SG(request_info
).request_uri
&& SG(request_info
).request_uri
[0]) {
105 const char *q
= strchr(SG(request_info
).request_uri
, '?');
107 url(buf
)->path
= &buf
.data
[buf
.used
];
110 php_http_buffer_append(&buf
, SG(request_info
).request_uri
, q
- SG(request_info
).request_uri
);
111 php_http_buffer_append(&buf
, "", 1);
113 php_http_buffer_append(&buf
, SG(request_info
).request_uri
, strlen(SG(request_info
).request_uri
) + 1);
118 if (SG(request_info
).query_string
&& SG(request_info
).query_string
[0]) {
119 url(buf
)->query
= &buf
.data
[buf
.used
];
120 php_http_buffer_append(&buf
, SG(request_info
).query_string
, strlen(SG(request_info
).query_string
) + 1);
126 #define url_isset(u,n) \
128 #define url_copy(n) do { \
129 if (url_isset(new_url, n)) { \
130 url(buf)->n = &buf.data[buf.used]; \
131 php_http_buffer_append(&buf, new_url->n, strlen(new_url->n) + 1); \
132 } else if (url_isset(old_url, n)) { \
133 url(buf)->n = &buf.data[buf.used]; \
134 php_http_buffer_append(&buf, old_url->n, strlen(old_url->n) + 1); \
138 php_http_url_t
*php_http_url_mod(const php_http_url_t
*old_url
, const php_http_url_t
*new_url
, unsigned flags
)
140 php_http_url_t
*tmp_url
= NULL
;
141 php_http_buffer_t buf
;
143 php_http_buffer_init_ex(&buf
, MAX(PHP_HTTP_BUFFER_DEFAULT_SIZE
, sizeof(php_http_url_t
)<<2), PHP_HTTP_BUFFER_INIT_PREALLOC
);
144 php_http_buffer_account(&buf
, sizeof(php_http_url_t
));
145 memset(buf
.data
, 0, buf
.used
);
147 /* set from env if requested */
148 if (flags
& PHP_HTTP_URL_FROM_ENV
) {
149 php_http_url_t
*env_url
= php_http_url_from_env();
151 old_url
= tmp_url
= php_http_url_mod(env_url
, old_url
, flags
^ PHP_HTTP_URL_FROM_ENV
);
152 php_http_url_free(&env_url
);
157 if (!(flags
& PHP_HTTP_URL_STRIP_USER
)) {
161 if (!(flags
& PHP_HTTP_URL_STRIP_PASS
)) {
167 if (!(flags
& PHP_HTTP_URL_STRIP_PORT
)) {
168 url(buf
)->port
= url_isset(new_url
, port
) ? new_url
->port
: ((old_url
) ? old_url
->port
: 0);
171 if (!(flags
& PHP_HTTP_URL_STRIP_PATH
)) {
172 if ((flags
& PHP_HTTP_URL_JOIN_PATH
) && url_isset(old_url
, path
) && url_isset(new_url
, path
) && *new_url
->path
!= '/') {
173 size_t old_path_len
= strlen(old_url
->path
), new_path_len
= strlen(new_url
->path
);
174 char *path
= ecalloc(1, old_path_len
+ new_path_len
+ 1 + 1);
176 strcat(path
, old_url
->path
);
177 if (path
[old_path_len
- 1] != '/') {
178 php_dirname(path
, old_path_len
);
181 strcat(path
, new_url
->path
);
183 url(buf
)->path
= &buf
.data
[buf
.used
];
184 if (path
[0] != '/') {
185 php_http_buffer_append(&buf
, "/", 1);
187 php_http_buffer_append(&buf
, path
, strlen(path
) + 1);
190 const char *path
= NULL
;
192 if (url_isset(new_url
, path
)) {
193 path
= new_url
->path
;
194 } else if (url_isset(old_url
, path
)) {
195 path
= old_url
->path
;
199 url(buf
)->path
= &buf
.data
[buf
.used
];
201 php_http_buffer_append(&buf
, path
, strlen(path
) + 1);
208 if (!(flags
& PHP_HTTP_URL_STRIP_QUERY
)) {
209 if ((flags
& PHP_HTTP_URL_JOIN_QUERY
) && url_isset(new_url
, query
) && url_isset(old_url
, query
)) {
214 ZVAL_STRING(&qstr
, old_url
->query
);
215 php_http_querystring_update(&qarr
, &qstr
, NULL
);
216 zval_ptr_dtor(&qstr
);
217 ZVAL_STRING(&qstr
, new_url
->query
);
218 php_http_querystring_update(&qarr
, &qstr
, NULL
);
219 zval_ptr_dtor(&qstr
);
222 php_http_querystring_update(&qarr
, NULL
, &qstr
);
224 url(buf
)->query
= &buf
.data
[buf
.used
];
225 php_http_buffer_append(&buf
, Z_STRVAL(qstr
), Z_STRLEN(qstr
) + 1);
234 if (!(flags
& PHP_HTTP_URL_STRIP_FRAGMENT
)) {
238 /* done with copy & combine & strip */
240 if (flags
& PHP_HTTP_URL_FROM_ENV
) {
241 /* free old_url we tainted above */
242 php_http_url_free(&tmp_url
);
245 /* replace directory references if path is not a single slash */
246 if ((flags
& PHP_HTTP_URL_SANITIZE_PATH
)
247 && url(buf
)->path
[0] && url(buf
)->path
[1]) {
248 char *ptr
, *end
= url(buf
)->path
+ strlen(url(buf
)->path
) + 1;
250 for (ptr
= strchr(url(buf
)->path
, '/'); ptr
; ptr
= strchr(ptr
, '/')) {
253 memmove(&ptr
[1], &ptr
[2], end
- &ptr
[2]);
263 memmove(&ptr
[1], &ptr
[3], end
- &ptr
[3]);
269 while (ptr
!= url(buf
)->path
) {
274 memmove(&ptr
[1], pos
, end
- pos
);
276 } else if (!ptr
[3]) {
295 /* unset default ports */
296 if (url(buf
)->port
) {
297 if ( ((url(buf
)->port
== 80) && !strcmp(url(buf
)->scheme
, "http"))
298 || ((url(buf
)->port
==443) && !strcmp(url(buf
)->scheme
, "https"))
307 char *php_http_url_to_string(const php_http_url_t
*url
, char **url_str
, size_t *url_len
, zend_bool persistent
)
309 php_http_buffer_t buf
;
311 php_http_buffer_init_ex(&buf
, PHP_HTTP_BUFFER_DEFAULT_SIZE
, persistent
?
312 PHP_HTTP_BUFFER_INIT_PERSISTENT
: 0);
314 if (url
->scheme
&& *url
->scheme
) {
315 php_http_buffer_appendl(&buf
, url
->scheme
);
316 php_http_buffer_appends(&buf
, "://");
317 } else if ((url
->user
&& *url
->user
) || (url
->host
&& *url
->host
)) {
318 php_http_buffer_appends(&buf
, "//");
321 if (url
->user
&& *url
->user
) {
322 php_http_buffer_appendl(&buf
, url
->user
);
323 if (url
->pass
&& *url
->pass
) {
324 php_http_buffer_appends(&buf
, ":");
325 php_http_buffer_appendl(&buf
, url
->pass
);
327 php_http_buffer_appends(&buf
, "@");
330 if (url
->host
&& *url
->host
) {
331 php_http_buffer_appendl(&buf
, url
->host
);
333 php_http_buffer_appendf(&buf
, ":%hu", url
->port
);
337 if (url
->path
&& *url
->path
) {
338 if (*url
->path
!= '/') {
339 php_http_buffer_appends(&buf
, "/");
341 php_http_buffer_appendl(&buf
, url
->path
);
342 } else if (buf
.used
) {
343 php_http_buffer_appends(&buf
, "/");
346 if (url
->query
&& *url
->query
) {
347 php_http_buffer_appends(&buf
, "?");
348 php_http_buffer_appendl(&buf
, url
->query
);
351 if (url
->fragment
&& *url
->fragment
) {
352 php_http_buffer_appends(&buf
, "#");
353 php_http_buffer_appendl(&buf
, url
->fragment
);
356 php_http_buffer_shrink(&buf
);
357 php_http_buffer_fix(&buf
);
370 php_http_url_t
*php_http_url_from_zval(zval
*value
, unsigned flags
)
373 php_http_url_t
*purl
;
375 switch (Z_TYPE_P(value
)) {
378 purl
= php_http_url_from_struct(HASH_OF(value
));
382 zs
= zval_get_string(value
);
383 purl
= php_http_url_parse(zs
->val
, zs
->len
, flags
);
384 zend_string_release(zs
);
390 php_http_url_t
*php_http_url_from_struct(HashTable
*ht
)
393 php_http_buffer_t buf
;
395 php_http_buffer_init_ex(&buf
, MAX(PHP_HTTP_BUFFER_DEFAULT_SIZE
, sizeof(php_http_url_t
)<<2), PHP_HTTP_BUFFER_INIT_PREALLOC
);
396 php_http_buffer_account(&buf
, sizeof(php_http_url_t
));
397 memset(buf
.data
, 0, buf
.used
);
399 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("scheme")))) {
400 zend_string
*zs
= zval_get_string(e
);
401 url(buf
)->scheme
= &buf
.data
[buf
.used
];
402 php_http_buffer_append(&buf
, zs
->val
, zs
->len
+ 1);
403 zend_string_release(zs
);
405 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("user")))) {
406 zend_string
*zs
= zval_get_string(e
);
407 url(buf
)->user
= &buf
.data
[buf
.used
];
408 php_http_buffer_append(&buf
, zs
->val
, zs
->len
+ 1);
409 zend_string_release(zs
);
411 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("pass")))) {
412 zend_string
*zs
= zval_get_string(e
);
413 url(buf
)->pass
= &buf
.data
[buf
.used
];
414 php_http_buffer_append(&buf
, zs
->val
, zs
->len
+ 1);
415 zend_string_release(zs
);
417 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("host")))) {
418 zend_string
*zs
= zval_get_string(e
);
419 url(buf
)->host
= &buf
.data
[buf
.used
];
420 php_http_buffer_append(&buf
, zs
->val
, zs
->len
+ 1);
421 zend_string_release(zs
);
423 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("port")))) {
424 url(buf
)->port
= (unsigned short) zval_get_long(e
);
426 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("path")))) {
427 zend_string
*zs
= zval_get_string(e
);
428 url(buf
)->path
= &buf
.data
[buf
.used
];
429 php_http_buffer_append(&buf
, zs
->val
, zs
->len
+ 1);
430 zend_string_release(zs
);
432 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("query")))) {
433 zend_string
*zs
= zval_get_string(e
);
434 url(buf
)->query
= &buf
.data
[buf
.used
];
435 php_http_buffer_append(&buf
, zs
->val
, zs
->len
+ 1);
436 zend_string_release(zs
);
438 if ((e
= zend_hash_str_find(ht
, ZEND_STRL("fragment")))) {
439 zend_string
*zs
= zval_get_string(e
);
440 url(buf
)->fragment
= &buf
.data
[buf
.used
];
441 php_http_buffer_append(&buf
, zs
->val
, zs
->len
+ 1);
442 zend_string_release(zs
);
448 HashTable
*php_http_url_to_struct(const php_http_url_t
*url
, zval
*strct
)
454 switch (Z_TYPE_P(strct
)) {
466 zend_hash_init(ht
, 8, NULL
, ZVAL_PTR_DTOR
, 0);
469 #define url_struct_add(part) \
470 if (Z_TYPE_P(strct) == IS_ARRAY) { \
471 zend_hash_str_update(Z_ARRVAL_P(strct), part, lenof(part), &tmp); \
473 zend_update_property(Z_OBJCE_P(strct), strct, part, lenof(part), &tmp); \
474 zval_ptr_dtor(&tmp); \
479 ZVAL_STRING(&tmp
, url
->scheme
);
480 url_struct_add("scheme");
483 ZVAL_STRING(&tmp
, url
->user
);
484 url_struct_add("user");
487 ZVAL_STRING(&tmp
, url
->pass
);
488 url_struct_add("pass");
491 ZVAL_STRING(&tmp
, url
->host
);
492 url_struct_add("host");
495 ZVAL_LONG(&tmp
, url
->port
);
496 url_struct_add("port");
499 ZVAL_STRING(&tmp
, url
->path
);
500 url_struct_add("path");
503 ZVAL_STRING(&tmp
, url
->query
);
504 url_struct_add("query");
507 ZVAL_STRING(&tmp
, url
->fragment
);
508 url_struct_add("fragment");
515 ZEND_RESULT_CODE
php_http_url_encode_hash(HashTable
*hash
, const char *pre_encoded_str
, size_t pre_encoded_len
, char **encoded_str
, size_t *encoded_len
)
517 const char *arg_sep_str
;
519 php_http_buffer_t
*qstr
= php_http_buffer_new();
521 php_http_url_argsep(&arg_sep_str
, &arg_sep_len
);
523 if (SUCCESS
!= php_http_url_encode_hash_ex(hash
, qstr
, arg_sep_str
, arg_sep_len
, "=", 1, pre_encoded_str
, pre_encoded_len
)) {
524 php_http_buffer_free(&qstr
);
528 php_http_buffer_data(qstr
, encoded_str
, encoded_len
);
529 php_http_buffer_free(&qstr
);
534 ZEND_RESULT_CODE
php_http_url_encode_hash_ex(HashTable
*hash
, php_http_buffer_t
*qstr
, const char *arg_sep_str
, size_t arg_sep_len
, const char *val_sep_str
, size_t val_sep_len
, const char *pre_encoded_str
, size_t pre_encoded_len
)
536 if (pre_encoded_len
&& pre_encoded_str
) {
537 php_http_buffer_append(qstr
, pre_encoded_str
, pre_encoded_len
);
540 if (!php_http_params_to_string(qstr
, hash
, arg_sep_str
, arg_sep_len
, "", 0, val_sep_str
, val_sep_len
, PHP_HTTP_PARAMS_QUERY
)) {
554 char buffer
[1]; /* last member */
557 void php_http_url_free(php_http_url_t
**url
)
565 php_http_url_t
*php_http_url_copy(const php_http_url_t
*url
, zend_bool persistent
)
568 const char *end
= NULL
, *url_ptr
= (const char *) url
;
571 end
= MAX(url
->scheme
, end
);
572 end
= MAX(url
->pass
, end
);
573 end
= MAX(url
->user
, end
);
574 end
= MAX(url
->host
, end
);
575 end
= MAX(url
->path
, end
);
576 end
= MAX(url
->query
, end
);
577 end
= MAX(url
->fragment
, end
);
580 end
+= strlen(end
) + 1;
581 cpy_ptr
= pecalloc(1, end
- url_ptr
, persistent
);
582 cpy
= (php_http_url_t
*) cpy_ptr
;
584 memcpy(cpy_ptr
+ sizeof(*cpy
), url_ptr
+ sizeof(*url
), end
- url_ptr
- sizeof(*url
));
586 cpy
->scheme
= url
->scheme
? cpy_ptr
+ (url
->scheme
- url_ptr
) : NULL
;
587 cpy
->pass
= url
->pass
? cpy_ptr
+ (url
->pass
- url_ptr
) : NULL
;
588 cpy
->user
= url
->user
? cpy_ptr
+ (url
->user
- url_ptr
) : NULL
;
589 cpy
->host
= url
->host
? cpy_ptr
+ (url
->host
- url_ptr
) : NULL
;
590 cpy
->path
= url
->path
? cpy_ptr
+ (url
->path
- url_ptr
) : NULL
;
591 cpy
->query
= url
->query
? cpy_ptr
+ (url
->query
- url_ptr
) : NULL
;
592 cpy
->fragment
= url
->fragment
? cpy_ptr
+ (url
->fragment
- url_ptr
) : NULL
;
594 cpy
= ecalloc(1, sizeof(*url
));
597 cpy
->port
= url
->port
;
602 static size_t parse_mb_utf8(unsigned *wc
, const char *ptr
, const char *end
)
605 size_t consumed
= utf8towc(&wchar
, (const unsigned char *) ptr
, end
- ptr
);
607 if (!consumed
|| consumed
== (size_t) -1) {
617 #ifdef PHP_HTTP_HAVE_WCHAR
618 static size_t parse_mb_loc(unsigned *wc
, const char *ptr
, const char *end
)
622 #if defined(HAVE_MBRTOWC)
625 consumed
= mbrtowc(&wchar
, ptr
, end
- ptr
, &ps
);
626 #elif defined(HAVE_MBTOWC)
627 consumed
= mbtowc(&wchar
, ptr
, end
- ptr
);
630 if (!consumed
|| consumed
== (size_t) -1) {
641 typedef enum parse_mb_what
{
650 static const char * const parse_what
[] = {
659 static const char parse_xdigits
[] = "0123456789ABCDEF";
661 static size_t parse_mb(struct parse_state
*state
, parse_mb_what_t what
, const char *ptr
, const char *end
, const char *begin
, zend_bool silent
)
666 if (state
->flags
& PHP_HTTP_URL_PARSE_MBUTF8
) {
667 consumed
= parse_mb_utf8(&wchar
, ptr
, end
);
669 #ifdef PHP_HTTP_HAVE_WCHAR
670 else if (state
->flags
& PHP_HTTP_URL_PARSE_MBLOC
) {
671 consumed
= parse_mb_loc(&wchar
, ptr
, end
);
676 if (!(state
->flags
& PHP_HTTP_URL_PARSE_TOPCT
) || what
== PARSE_HOSTINFO
|| what
== PARSE_SCHEME
) {
677 if (what
== PARSE_HOSTINFO
&& (state
->flags
& PHP_HTTP_URL_PARSE_TOIDN
)) {
679 } else if (state
->flags
& PHP_HTTP_URL_PARSE_MBUTF8
) {
680 if (!isualnum(wchar
)) {
683 #ifdef PHP_HTTP_HAVE_WCHAR
684 } else if (state
->flags
& PHP_HTTP_URL_PARSE_MBLOC
) {
685 if (!iswalnum(wchar
)) {
690 PHP_HTTP_DUFF(consumed
, state
->buffer
[state
->offset
++] = *ptr
++);
694 PHP_HTTP_DUFF(consumed
,
695 state
->buffer
[state
->offset
++] = '%';
696 state
->buffer
[state
->offset
++] = parse_xdigits
[((unsigned char) ptr
[i
]) >> 4];
697 state
->buffer
[state
->offset
++] = parse_xdigits
[((unsigned char) ptr
[i
]) & 0xf];
706 php_error_docref(NULL
, E_WARNING
,
707 "Failed to parse %s; unexpected byte 0x%02x at pos %u in '%s'",
708 parse_what
[what
], (unsigned char) *ptr
, (unsigned) (ptr
- begin
), begin
);
714 static ZEND_RESULT_CODE
parse_userinfo(struct parse_state
*state
, const char *ptr
)
717 const char *password
= NULL
, *end
= state
->ptr
, *tmp
= ptr
;
719 state
->url
.user
= &state
->buffer
[state
->offset
];
725 php_error_docref(NULL
, E_WARNING
,
726 "Failed to parse password; duplicate ':' at pos %u in '%s'",
727 (unsigned) (ptr
- tmp
), tmp
);
731 state
->buffer
[state
->offset
++] = 0;
732 state
->url
.pass
= &state
->buffer
[state
->offset
];
736 if (ptr
[1] != '%' && (end
- ptr
<= 2 || !isxdigit(*(ptr
+1)) || !isxdigit(*(ptr
+2)))) {
737 php_error_docref(NULL
, E_WARNING
,
738 "Failed to parse userinfo; invalid percent encoding at pos %u in '%s'",
739 (unsigned) (ptr
- tmp
), tmp
);
742 state
->buffer
[state
->offset
++] = *ptr
++;
743 state
->buffer
[state
->offset
++] = *ptr
++;
744 state
->buffer
[state
->offset
++] = *ptr
;
747 case '!': case '$': case '&': case '\'': case '(': case ')': case '*':
748 case '+': case ',': case ';': case '=': /* sub-delims */
749 case '-': case '.': case '_': case '~': /* unreserved */
750 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
751 case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
752 case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
753 case 'V': case 'W': case 'X': case 'Y': case 'Z':
754 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
755 case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
756 case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
757 case 'v': case 'w': case 'x': case 'y': case 'z':
758 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
759 case '7': case '8': case '9':
761 state
->buffer
[state
->offset
++] = *ptr
;
765 if (!(mb
= parse_mb(state
, PARSE_USERINFO
, ptr
, end
, tmp
, 0))) {
770 } while(++ptr
!= end
);
773 state
->buffer
[state
->offset
++] = 0;
778 static ZEND_RESULT_CODE
parse_hostinfo(struct parse_state
*state
, const char *ptr
)
781 const char *end
= state
->ptr
, *tmp
= ptr
, *port
= NULL
;
784 #ifdef HAVE_INET_PTON
786 char *error
= NULL
, *tmp
= memchr(ptr
, ']', end
- ptr
);
789 size_t addrlen
= tmp
- ptr
+ 1;
790 char buf
[16], *addr
= estrndup(ptr
+ 1, addrlen
- 2);
791 int rv
= inet_pton(AF_INET6
, addr
, buf
);
795 state
->buffer
[state
->offset
] = '[';
796 state
->url
.host
= &state
->buffer
[state
->offset
];
797 inet_ntop(AF_INET6
, buf
, state
->url
.host
+ 1, state
->maxlen
- state
->offset
);
798 state
->offset
+= strlen(state
->url
.host
);
799 state
->buffer
[state
->offset
++] = ']';
800 state
->buffer
[state
->offset
++] = 0;
802 } else if (rv
== -1) {
803 error
= strerror(errno
);
805 error
= "unexpected '['";
808 error
= "expected ']'";
812 php_error_docref(NULL
, E_WARNING
, "Failed to parse hostinfo; %s", error
);
821 php_error_docref(NULL
, E_WARNING
,
822 "Failed to parse port; unexpected ':' at pos %u in '%s'",
823 (unsigned) (ptr
- tmp
), tmp
);
830 if (ptr
[1] != '%' && (end
- ptr
<= 2 || !isxdigit(*(ptr
+1)) || !isxdigit(*(ptr
+2)))) {
831 php_error_docref(NULL
, E_WARNING
,
832 "Failed to parse hostinfo; invalid percent encoding at pos %u in '%s'",
833 (unsigned) (ptr
- tmp
), tmp
);
836 state
->buffer
[state
->offset
++] = *ptr
++;
837 state
->buffer
[state
->offset
++] = *ptr
++;
838 state
->buffer
[state
->offset
++] = *ptr
;
841 case '!': case '$': case '&': case '\'': case '(': case ')': case '*':
842 case '+': case ',': case ';': case '=': /* sub-delims */
843 case '-': case '.': case '_': case '~': /* unreserved */
844 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
845 case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
846 case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
847 case 'V': case 'W': case 'X': case 'Y': case 'Z':
848 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
849 case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
850 case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
851 case 'v': case 'w': case 'x': case 'y': case 'z':
853 php_error_docref(NULL
, E_WARNING
,
854 "Failed to parse port; unexpected char '%c' at pos %u in '%s'",
855 (unsigned char) *ptr
, (unsigned) (ptr
- tmp
), tmp
);
859 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
860 case '7': case '8': case '9':
863 state
->url
.port
*= 10;
864 state
->url
.port
+= *ptr
- '0';
866 state
->buffer
[state
->offset
++] = *ptr
;
872 php_error_docref(NULL
, E_WARNING
,
873 "Failed to parse port; unexpected byte 0x%02x at pos %u in '%s'",
874 (unsigned char) *ptr
, (unsigned) (ptr
- tmp
), tmp
);
876 } else if (!(mb
= parse_mb(state
, PARSE_HOSTINFO
, ptr
, end
, tmp
, 0))) {
881 } while (++ptr
!= end
);
883 if (!state
->url
.host
) {
884 len
= (port
? port
- tmp
- 1 : end
- tmp
);
885 state
->url
.host
= &state
->buffer
[state
->offset
- len
];
886 state
->buffer
[state
->offset
++] = 0;
889 #ifdef PHP_HTTP_HAVE_IDN
890 if (state
->flags
& PHP_HTTP_URL_PARSE_TOIDN
) {
894 if (state
->flags
& PHP_HTTP_URL_PARSE_MBUTF8
) {
895 rv
= idna_to_ascii_8z(state
->url
.host
, &idn
, IDNA_ALLOW_UNASSIGNED
|IDNA_USE_STD3_ASCII_RULES
);
897 # ifdef PHP_HTTP_HAVE_WCHAR
898 else if (state
->flags
& PHP_HTTP_URL_PARSE_MBLOC
) {
899 rv
= idna_to_ascii_lz(state
->url
.host
, &idn
, IDNA_ALLOW_UNASSIGNED
|IDNA_USE_STD3_ASCII_RULES
);
902 if (rv
!= IDNA_SUCCESS
) {
903 php_error_docref(NULL
, E_WARNING
, "Failed to parse IDN; %s", idna_strerror(rv
));
906 size_t idnlen
= strlen(idn
);
907 memcpy(state
->url
.host
, idn
, idnlen
+ 1);
909 state
->offset
+= idnlen
- len
;
917 static const char *parse_authority(struct parse_state
*state
)
919 const char *tmp
= state
->ptr
, *host
= NULL
;
922 switch (*state
->ptr
) {
924 /* userinfo delimiter */
926 php_error_docref(NULL
, E_WARNING
,
927 "Failed to parse userinfo; unexpected '@'");
930 host
= state
->ptr
+ 1;
931 if (tmp
!= state
->ptr
&& SUCCESS
!= parse_userinfo(state
, tmp
)) {
934 tmp
= state
->ptr
+ 1;
942 if (tmp
!= state
->ptr
&& SUCCESS
!= parse_hostinfo(state
, tmp
)) {
947 } while (++state
->ptr
<= state
->end
);
952 static const char *parse_path(struct parse_state
*state
)
957 /* is there actually a path to parse? */
962 state
->url
.path
= &state
->buffer
[state
->offset
];
965 switch (*state
->ptr
) {
971 if (state
->ptr
[1] != '%' && (state
->end
- state
->ptr
<= 2 || !isxdigit(*(state
->ptr
+1)) || !isxdigit(*(state
->ptr
+2)))) {
972 php_error_docref(NULL
, E_WARNING
,
973 "Failed to parse path; invalid percent encoding at pos %u in '%s'",
974 (unsigned) (state
->ptr
- tmp
), tmp
);
977 state
->buffer
[state
->offset
++] = *state
->ptr
++;
978 state
->buffer
[state
->offset
++] = *state
->ptr
++;
979 state
->buffer
[state
->offset
++] = *state
->ptr
;
982 case '/': /* yeah, well */
983 case '!': case '$': case '&': case '\'': case '(': case ')': case '*':
984 case '+': case ',': case ';': case '=': /* sub-delims */
985 case '-': case '.': case '_': case '~': /* unreserved */
986 case ':': case '@': /* pchar */
987 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
988 case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
989 case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
990 case 'V': case 'W': case 'X': case 'Y': case 'Z':
991 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
992 case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
993 case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
994 case 'v': case 'w': case 'x': case 'y': case 'z':
995 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
996 case '7': case '8': case '9':
998 state
->buffer
[state
->offset
++] = *state
->ptr
;
1002 if (!(mb
= parse_mb(state
, PARSE_PATH
, state
->ptr
, state
->end
, tmp
, 0))) {
1005 state
->ptr
+= mb
- 1;
1007 } while (++state
->ptr
< state
->end
);
1010 /* did we have any path component ? */
1011 if (tmp
!= state
->ptr
) {
1012 state
->buffer
[state
->offset
++] = 0;
1014 state
->url
.path
= NULL
;
1019 static const char *parse_query(struct parse_state
*state
)
1022 const char *tmp
= state
->ptr
+ !!*state
->ptr
;
1024 /* is there actually a query to parse? */
1025 if (*state
->ptr
!= '?') {
1029 /* skip initial '?' */
1031 state
->url
.query
= &state
->buffer
[state
->offset
];
1034 switch (*state
->ptr
) {
1039 if (state
->ptr
[1] != '%' && (state
->end
- state
->ptr
<= 2 || !isxdigit(*(state
->ptr
+1)) || !isxdigit(*(state
->ptr
+2)))) {
1040 php_error_docref(NULL
, E_WARNING
,
1041 "Failed to parse query; invalid percent encoding at pos %u in '%s'",
1042 (unsigned) (state
->ptr
- tmp
), tmp
);
1045 state
->buffer
[state
->offset
++] = *state
->ptr
++;
1046 state
->buffer
[state
->offset
++] = *state
->ptr
++;
1047 state
->buffer
[state
->offset
++] = *state
->ptr
;
1052 if (state
->flags
& PHP_HTTP_URL_PARSE_TOPCT
) {
1053 state
->buffer
[state
->offset
++] = '%';
1054 state
->buffer
[state
->offset
++] = parse_xdigits
[((unsigned char) *state
->ptr
) >> 4];
1055 state
->buffer
[state
->offset
++] = parse_xdigits
[((unsigned char) *state
->ptr
) & 0xf];
1060 case '?': case '/': /* yeah, well */
1061 case '!': case '$': case '&': case '\'': case '(': case ')': case '*':
1062 case '+': case ',': case ';': case '=': /* sub-delims */
1063 case '-': case '.': case '_': case '~': /* unreserved */
1064 case ':': case '@': /* pchar */
1065 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
1066 case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
1067 case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
1068 case 'V': case 'W': case 'X': case 'Y': case 'Z':
1069 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
1070 case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
1071 case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
1072 case 'v': case 'w': case 'x': case 'y': case 'z':
1073 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
1074 case '7': case '8': case '9':
1076 state
->buffer
[state
->offset
++] = *state
->ptr
;
1080 if (!(mb
= parse_mb(state
, PARSE_QUERY
, state
->ptr
, state
->end
, tmp
, 0))) {
1083 state
->ptr
+= mb
- 1;
1085 } while (++state
->ptr
< state
->end
);
1088 state
->buffer
[state
->offset
++] = 0;
1092 static const char *parse_fragment(struct parse_state
*state
)
1097 /* is there actually a fragment to parse? */
1098 if (*state
->ptr
!= '#') {
1102 /* skip initial '#' */
1104 state
->url
.fragment
= &state
->buffer
[state
->offset
];
1107 switch (*state
->ptr
) {
1109 if (state
->ptr
[1] != '%' && (state
->end
- state
->ptr
<= 2 || !isxdigit(*(state
->ptr
+1)) || !isxdigit(*(state
->ptr
+2)))) {
1110 php_error_docref(NULL
, E_WARNING
,
1111 "Failed to parse fragment; invalid percent encoding at pos %u in '%s'",
1112 (unsigned) (state
->ptr
- tmp
), tmp
);
1115 state
->buffer
[state
->offset
++] = *state
->ptr
++;
1116 state
->buffer
[state
->offset
++] = *state
->ptr
++;
1117 state
->buffer
[state
->offset
++] = *state
->ptr
;
1121 case '!': case '$': case '&': case '\'': case '(': case ')': case '*':
1122 case '+': case ',': case ';': case '=': /* sub-delims */
1123 case '-': case '.': case '_': case '~': /* unreserved */
1124 case ':': case '@': /* pchar */
1125 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
1126 case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
1127 case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
1128 case 'V': case 'W': case 'X': case 'Y': case 'Z':
1129 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
1130 case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
1131 case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
1132 case 'v': case 'w': case 'x': case 'y': case 'z':
1133 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
1134 case '7': case '8': case '9':
1136 state
->buffer
[state
->offset
++] = *state
->ptr
;
1140 if (!(mb
= parse_mb(state
, PARSE_FRAGMENT
, state
->ptr
, state
->end
, tmp
, 0))) {
1143 state
->ptr
+= mb
- 1;
1145 } while (++state
->ptr
< state
->end
);
1147 state
->buffer
[state
->offset
++] = 0;
1151 static const char *parse_hier(struct parse_state
*state
)
1153 if (*state
->ptr
== '/') {
1154 if (state
->end
- state
->ptr
> 1) {
1155 if (*(state
->ptr
+ 1) == '/') {
1157 if (!(state
->ptr
= parse_authority(state
))) {
1163 return parse_path(state
);
1166 static const char *parse_scheme(struct parse_state
*state
)
1169 const char *tmp
= state
->ptr
;
1172 switch (*state
->ptr
) {
1174 /* scheme delimiter */
1175 state
->url
.scheme
= &state
->buffer
[0];
1176 state
->buffer
[state
->offset
++] = 0;
1177 return ++state
->ptr
;
1179 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
1180 case '7': case '8': case '9':
1181 case '+': case '-': case '.':
1182 if (state
->ptr
== tmp
) {
1186 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
1187 case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
1188 case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
1189 case 'V': case 'W': case 'X': case 'Y': case 'Z':
1190 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
1191 case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
1192 case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
1193 case 'v': case 'w': case 'x': case 'y': case 'z':
1195 state
->buffer
[state
->offset
++] = *state
->ptr
;
1199 if (!(mb
= parse_mb(state
, PARSE_SCHEME
, state
->ptr
, state
->end
, tmp
, 1))) {
1200 /* soft fail; parse path next */
1203 state
->ptr
+= mb
- 1;
1205 } while (++state
->ptr
!= state
->end
);
1207 return state
->ptr
= tmp
;
1210 php_http_url_t
*php_http_url_parse(const char *str
, size_t len
, unsigned flags
)
1212 size_t maxlen
= 3 * len
;
1213 struct parse_state
*state
= ecalloc(1, sizeof(*state
) + maxlen
);
1215 state
->end
= str
+ len
;
1217 state
->flags
= flags
;
1218 state
->maxlen
= maxlen
;
1220 if (!parse_scheme(state
)) {
1221 php_error_docref(NULL
, E_WARNING
, "Failed to parse URL scheme: '%s'", state
->ptr
);
1226 if (!parse_hier(state
)) {
1231 if (!parse_query(state
)) {
1232 php_error_docref(NULL
, E_WARNING
, "Failed to parse URL query: '%s'", state
->ptr
);
1237 if (!parse_fragment(state
)) {
1238 php_error_docref(NULL
, E_WARNING
, "Failed to parse URL fragment: '%s'", state
->ptr
);
1243 return (php_http_url_t
*) state
;
1246 ZEND_BEGIN_ARG_INFO_EX(ai_HttpUrl___construct
, 0, 0, 0)
1247 ZEND_ARG_INFO(0, old_url
)
1248 ZEND_ARG_INFO(0, new_url
)
1249 ZEND_ARG_INFO(0, flags
)
1250 ZEND_END_ARG_INFO();
1251 PHP_METHOD(HttpUrl
, __construct
)
1253 zval
*new_url
= NULL
, *old_url
= NULL
;
1254 zend_long flags
= PHP_HTTP_URL_FROM_ENV
;
1255 zend_error_handling zeh
;
1257 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "|z!z!l", &old_url
, &new_url
, &flags
), invalid_arg
, return);
1259 zend_replace_error_handling(EH_THROW
, php_http_exception_bad_url_class_entry
, &zeh
);
1261 php_http_url_t
*res_purl
, *new_purl
= NULL
, *old_purl
= NULL
;
1264 new_purl
= php_http_url_from_zval(new_url
, flags
);
1266 zend_restore_error_handling(&zeh
);
1271 old_purl
= php_http_url_from_zval(old_url
, flags
);
1274 php_http_url_free(&new_purl
);
1276 zend_restore_error_handling(&zeh
);
1281 res_purl
= php_http_url_mod(old_purl
, new_purl
, flags
);
1282 php_http_url_to_struct(res_purl
, getThis());
1284 php_http_url_free(&res_purl
);
1286 php_http_url_free(&old_purl
);
1289 php_http_url_free(&new_purl
);
1292 zend_restore_error_handling(&zeh
);
1295 ZEND_BEGIN_ARG_INFO_EX(ai_HttpUrl_mod
, 0, 0, 1)
1296 ZEND_ARG_INFO(0, more_url_parts
)
1297 ZEND_ARG_INFO(0, flags
)
1298 ZEND_END_ARG_INFO();
1299 PHP_METHOD(HttpUrl
, mod
)
1301 zval
*new_url
= NULL
;
1302 zend_long flags
= PHP_HTTP_URL_JOIN_PATH
| PHP_HTTP_URL_JOIN_QUERY
;
1303 zend_error_handling zeh
;
1305 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS(), "z!|l", &new_url
, &flags
), invalid_arg
, return);
1307 zend_replace_error_handling(EH_THROW
, php_http_exception_bad_url_class_entry
, &zeh
);
1309 php_http_url_t
*new_purl
= NULL
, *old_purl
= NULL
;
1312 new_purl
= php_http_url_from_zval(new_url
, flags
);
1314 zend_restore_error_handling(&zeh
);
1319 if ((old_purl
= php_http_url_from_struct(HASH_OF(getThis())))) {
1320 php_http_url_t
*res_purl
;
1322 ZVAL_OBJ(return_value
, zend_objects_clone_obj(getThis()));
1324 res_purl
= php_http_url_mod(old_purl
, new_purl
, flags
);
1325 php_http_url_to_struct(res_purl
, return_value
);
1327 php_http_url_free(&res_purl
);
1328 php_http_url_free(&old_purl
);
1331 php_http_url_free(&new_purl
);
1334 zend_restore_error_handling(&zeh
);
1337 ZEND_BEGIN_ARG_INFO_EX(ai_HttpUrl_toString
, 0, 0, 0)
1338 ZEND_END_ARG_INFO();
1339 PHP_METHOD(HttpUrl
, toString
)
1341 if (SUCCESS
== zend_parse_parameters_none()) {
1342 php_http_url_t
*purl
;
1344 if ((purl
= php_http_url_from_struct(HASH_OF(getThis())))) {
1348 php_http_url_to_string(purl
, &str
, &len
, 0);
1349 php_http_url_free(&purl
);
1350 RETURN_STR(php_http_cs2zs(str
, len
));
1353 RETURN_EMPTY_STRING();
1356 ZEND_BEGIN_ARG_INFO_EX(ai_HttpUrl_toArray
, 0, 0, 0)
1357 ZEND_END_ARG_INFO();
1358 PHP_METHOD(HttpUrl
, toArray
)
1360 php_http_url_t
*purl
;
1362 if (SUCCESS
!= zend_parse_parameters_none()) {
1366 /* strip any non-URL properties */
1367 purl
= php_http_url_from_struct(HASH_OF(getThis()));
1368 php_http_url_to_struct(purl
, return_value
);
1369 php_http_url_free(&purl
);
1372 static zend_function_entry php_http_url_methods
[] = {
1373 PHP_ME(HttpUrl
, __construct
, ai_HttpUrl___construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
)
1374 PHP_ME(HttpUrl
, mod
, ai_HttpUrl_mod
, ZEND_ACC_PUBLIC
)
1375 PHP_ME(HttpUrl
, toString
, ai_HttpUrl_toString
, ZEND_ACC_PUBLIC
)
1376 ZEND_MALIAS(HttpUrl
, __toString
, toString
, ai_HttpUrl_toString
, ZEND_ACC_PUBLIC
)
1377 PHP_ME(HttpUrl
, toArray
, ai_HttpUrl_toArray
, ZEND_ACC_PUBLIC
)
1378 EMPTY_FUNCTION_ENTRY
1381 zend_class_entry
*php_http_url_class_entry
;
1383 PHP_MINIT_FUNCTION(http_url
)
1385 zend_class_entry ce
= {0};
1387 INIT_NS_CLASS_ENTRY(ce
, "http", "Url", php_http_url_methods
);
1388 php_http_url_class_entry
= zend_register_internal_class(&ce
);
1390 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("scheme"), ZEND_ACC_PUBLIC
);
1391 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("user"), ZEND_ACC_PUBLIC
);
1392 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("pass"), ZEND_ACC_PUBLIC
);
1393 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("host"), ZEND_ACC_PUBLIC
);
1394 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("port"), ZEND_ACC_PUBLIC
);
1395 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("path"), ZEND_ACC_PUBLIC
);
1396 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("query"), ZEND_ACC_PUBLIC
);
1397 zend_declare_property_null(php_http_url_class_entry
, ZEND_STRL("fragment"), ZEND_ACC_PUBLIC
);
1399 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("REPLACE"), PHP_HTTP_URL_REPLACE
);
1400 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("JOIN_PATH"), PHP_HTTP_URL_JOIN_PATH
);
1401 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("JOIN_QUERY"), PHP_HTTP_URL_JOIN_QUERY
);
1402 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_USER"), PHP_HTTP_URL_STRIP_USER
);
1403 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_PASS"), PHP_HTTP_URL_STRIP_PASS
);
1404 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_AUTH"), PHP_HTTP_URL_STRIP_AUTH
);
1405 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_PORT"), PHP_HTTP_URL_STRIP_PORT
);
1406 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_PATH"), PHP_HTTP_URL_STRIP_PATH
);
1407 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_QUERY"), PHP_HTTP_URL_STRIP_QUERY
);
1408 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_FRAGMENT"), PHP_HTTP_URL_STRIP_FRAGMENT
);
1409 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("STRIP_ALL"), PHP_HTTP_URL_STRIP_ALL
);
1410 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("FROM_ENV"), PHP_HTTP_URL_FROM_ENV
);
1411 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("SANITIZE_PATH"), PHP_HTTP_URL_SANITIZE_PATH
);
1413 #ifdef PHP_HTTP_HAVE_WCHAR
1414 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("PARSE_MBLOC"), PHP_HTTP_URL_PARSE_MBLOC
);
1416 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("PARSE_MBUTF8"), PHP_HTTP_URL_PARSE_MBUTF8
);
1417 #ifdef PHP_HTTP_HAVE_IDN
1418 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("PARSE_TOIDN"), PHP_HTTP_URL_PARSE_TOIDN
);
1420 zend_declare_class_constant_long(php_http_url_class_entry
, ZEND_STRL("PARSE_TOPCT"), PHP_HTTP_URL_PARSE_TOPCT
);
1431 * vim600: noet sw=4 ts=4 fdm=marker
1432 * vim<600: noet sw=4 ts=4