diff options
| author | Ondřej Surý <ondrej@sury.org> | 2013-02-25 16:11:05 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2013-02-25 16:11:05 +0100 |
| commit | c8013604b48675ec2b266aa186bb6c3126c47cca (patch) | |
| tree | de627cca2457af7c3c0a6498906ff49b4d2f722d /ext/standard | |
| parent | 28f17d3b49950d50f3900f84d74d7cc0822b123d (diff) | |
| download | php-upstream/5.4.12.tar.gz | |
Imported Upstream version 5.4.12upstream/5.4.12
Diffstat (limited to 'ext/standard')
| -rw-r--r-- | ext/standard/html.c | 4 | ||||
| -rw-r--r-- | ext/standard/http_fopen_wrapper.c | 6 | ||||
| -rw-r--r-- | ext/standard/image.c | 2 | ||||
| -rw-r--r-- | ext/standard/string.c | 453 | ||||
| -rw-r--r-- | ext/standard/tests/image/getimagesize.phpt | 17 | ||||
| -rw-r--r-- | ext/standard/tests/image/image_type_to_mime_type.phpt | 10 | ||||
| -rw-r--r-- | ext/standard/tests/image/test1bpix.bmp | bin | 0 -> 690138 bytes | |||
| -rw-r--r-- | ext/standard/tests/strings/bug63943.phpt | 8 | ||||
| -rw-r--r-- | ext/standard/tests/strings/get_html_translation_table_basic10.phpt | 121 | ||||
| -rw-r--r-- | ext/standard/tests/strings/strpos.phpt | bin | 9990 -> 9981 bytes | |||
| -rw-r--r-- | ext/standard/var_unserializer.c | 2 | ||||
| -rw-r--r-- | ext/standard/var_unserializer.re | 6 |
12 files changed, 530 insertions, 99 deletions
diff --git a/ext/standard/html.c b/ext/standard/html.c index 79a6737ca..414fa65c9 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1628,8 +1628,8 @@ PHP_FUNCTION(get_html_translation_table) unsigned i, j, k, max_i, max_j, max_k; /* no mapping to unicode required */ - if (CHARSET_SINGLE_BYTE(charset)) { - max_i = 1; max_j = 1; max_k = 64; + if (CHARSET_SINGLE_BYTE(charset)) { /* ISO-8859-1 */ + max_i = 1; max_j = 4; max_k = 64; } else { max_i = 0x1E; max_j = 64; max_k = 64; } diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 85a61167a..870f904e9 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -113,6 +113,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0); int follow_location = 1; php_stream_filter *transfer_encoding = NULL; + int response_code; tmp_line[0] = '\0'; @@ -657,7 +658,6 @@ finish: if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) { zval *http_response; - int response_code; if (tmp_line_len > 9) { response_code = atoi(tmp_line + 9); @@ -731,7 +731,9 @@ finish: http_header_line[http_header_line_length] = '\0'; if (!strncasecmp(http_header_line, "Location: ", 10)) { - if (context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) { + /* we only care about Location for 300, 301, 302, 303 and 307 */ + /* see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1 */ + if ((response_code >= 300 && response_code < 304 || 307 == response_code) && context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) { SEPARATE_ZVAL(tmpzval); convert_to_long_ex(tmpzval); follow_location = Z_LVAL_PP(tmpzval); diff --git a/ext/standard/image.c b/ext/standard/image.c index ebf894aa5..4984e4064 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -159,7 +159,7 @@ static struct gfxinfo *php_handle_bmp (php_stream * stream TSRMLS_DC) result->width = (((unsigned int)dim[ 5]) << 8) + ((unsigned int) dim[ 4]); result->height = (((unsigned int)dim[ 7]) << 8) + ((unsigned int) dim[ 6]); result->bits = ((unsigned int)dim[11]); - } else if (size > 12 && (size <= 64 || size == 108)) { + } else if (size > 12 && (size <= 64 || size == 108 || size == 124)) { result = (struct gfxinfo *) ecalloc (1, sizeof(struct gfxinfo)); result->width = (((unsigned int)dim[ 7]) << 24) + (((unsigned int)dim[ 6]) << 16) + (((unsigned int)dim[ 5]) << 8) + ((unsigned int) dim[ 4]); result->height = (((unsigned int)dim[11]) << 24) + (((unsigned int)dim[10]) << 16) + (((unsigned int)dim[ 9]) << 8) + ((unsigned int) dim[ 8]); diff --git a/ext/standard/string.c b/ext/standard/string.c index cf973300b..42bf19817 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -23,6 +23,11 @@ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ #include <stdio.h> +#ifdef PHP_WIN32 +# include "win32/php_stdint.h" +#else +# include <stdint.h> +#endif #include "php.h" #include "php_rand.h" #include "php_string.h" @@ -57,6 +62,7 @@ #include "php_globals.h" #include "basic_functions.h" #include "php_smart_str.h" +#include <Zend/zend_exceptions.h> #ifdef ZTS #include "TSRM.h" #endif @@ -132,7 +138,7 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t * size_t i, j; result = (unsigned char *) safe_emalloc(oldlen, 2 * sizeof(char), 1); - + for (i = j = 0; i < oldlen; i++) { result[j++] = hexconvtab[old[i] >> 4]; result[j++] = hexconvtab[old[i] & 15]; @@ -1811,7 +1817,7 @@ PHP_FUNCTION(strpos) if (Z_TYPE_P(needle) == IS_STRING) { if (!Z_STRLEN_P(needle)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty needle"); RETURN_FALSE; } @@ -2772,112 +2778,383 @@ PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trl } /* }}} */ -/* {{{ php_strtr_array - */ -static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *hash) +/* {{{ Definitions for php_strtr_array */ +typedef size_t STRLEN; /* STRLEN should be unsigned */ +typedef uint16_t HASH; +typedef struct { + HASH table_mask; + STRLEN entries[1]; +} SHIFT_TAB; +typedef struct { + HASH table_mask; + int entries[1]; +} HASH_TAB; +typedef struct { + const char *s; + STRLEN l; +} STR; +typedef struct _pat_and_repl { + STR pat; + STR repl; +} PATNREPL; + +#define S(a) ((a)->s) +#define L(a) ((a)->l) + +#define SHIFT_TAB_BITS 13 +#define HASH_TAB_BITS 10 /* should be less than sizeof(HASH) * 8 */ +#define SHIFT_TAB_SIZE (1U << SHIFT_TAB_BITS) +#define HASH_TAB_SIZE (1U << HASH_TAB_BITS) + +typedef struct { + int B; /* size of suffixes */ + int Bp; /* size of prefixes */ + STRLEN m; /* minimum pattern length */ + int patnum; /* number of patterns */ + SHIFT_TAB *shift; /* table mapping hash to allowed shift */ + HASH_TAB *hash; /* table mapping hash to int (pair of pointers) */ + HASH *prefix; /* array of hashes of prefixes by pattern suffix hash order */ + PATNREPL *patterns; /* array of prefixes by pattern suffix hash order */ +} PPRES; +/* }}} */ + +/* {{{ php_strtr_hash */ +static inline HASH php_strtr_hash(const char *str, int len) { - zval **entry; - char *string_key; - uint string_key_len; - zval **trans; - zval ctmp; - ulong num_key; - int minlen = 128*1024; - int maxlen = 0, pos, len, found; - char *key; - HashPosition hpos; - smart_str result = {0}; - HashTable tmp_hash; - - zend_hash_init(&tmp_hash, zend_hash_num_elements(hash), NULL, NULL, 0); - zend_hash_internal_pointer_reset_ex(hash, &hpos); - while (zend_hash_get_current_data_ex(hash, (void **)&entry, &hpos) == SUCCESS) { - switch (zend_hash_get_current_key_ex(hash, &string_key, &string_key_len, &num_key, 0, &hpos)) { - case HASH_KEY_IS_STRING: - len = string_key_len-1; - if (len < 1) { - zend_hash_destroy(&tmp_hash); - RETURN_FALSE; - } - zend_hash_add(&tmp_hash, string_key, string_key_len, entry, sizeof(zval*), NULL); - if (len > maxlen) { - maxlen = len; - } - if (len < minlen) { - minlen = len; - } - break; + HASH res = 0; + int i; + for (i = 0; i < len; i++) { + res = res * 33 + (unsigned char)str[i]; + } - case HASH_KEY_IS_LONG: - Z_TYPE(ctmp) = IS_LONG; - Z_LVAL(ctmp) = num_key; + return res; +} +/* }}} */ +/* {{{ php_strtr_populate_shift */ +static inline void php_strtr_populate_shift(PATNREPL *patterns, int patnum, int B, STRLEN m, SHIFT_TAB *shift) +{ + int i; + STRLEN j, + max_shift; + + max_shift = m - B + 1; + for (i = 0; i < SHIFT_TAB_SIZE; i++) { + shift->entries[i] = max_shift; + } + for (i = 0; i < patnum; i++) { + for (j = 0; j < m - B + 1; j++) { + HASH h = php_strtr_hash(&S(&patterns[i].pat)[j], B) & shift->table_mask; + assert((long long) m - (long long) j - B >= 0); + shift->entries[h] = MIN(shift->entries[h], m - j - B); + } + } +} +/* }}} */ +/* {{{ php_strtr_compare_hash_suffix */ +static int php_strtr_compare_hash_suffix(const void *a, const void *b, void *ctx_g) +{ + const PPRES *res = ctx_g; + const PATNREPL *pnr_a = a, + *pnr_b = b; + HASH hash_a = php_strtr_hash(&S(&pnr_a->pat)[res->m - res->B], res->B) + & res->hash->table_mask, + hash_b = php_strtr_hash(&S(&pnr_b->pat)[res->m - res->B], res->B) + & res->hash->table_mask; + /* TODO: don't recalculate the hashes all the time */ + if (hash_a > hash_b) { + return 1; + } else if (hash_a < hash_b) { + return -1; + } else { + /* longer patterns must be sorted first */ + if (L(&pnr_a->pat) > L(&pnr_b->pat)) { + return -1; + } else if (L(&pnr_a->pat) < L(&pnr_b->pat)) { + return 1; + } else { + return 0; + } + } +} +/* }}} */ +/* {{{ Sorting (no zend_qsort_r in this PHP version) */ +#define HS_LEFT(i) ((i) * 2 + 1) +#define HS_RIGHT(i) ((i) * 2 + 2) +#define HS_PARENT(i) (((i) - 1) / 2); +#define HS_OFF(data, i) ((void *)(&((data)->arr)[i])) +#define HS_CMP_CALL(data, i1, i2) \ + (php_strtr_compare_hash_suffix(HS_OFF((data), (i1)), HS_OFF((data), (i2)), (data)->res)) +struct hs_data { + PATNREPL *arr; + size_t nel; + size_t heapel; + PPRES *res; +}; +static inline void php_strtr_swap(PATNREPL *a, PATNREPL *b) +{ + PATNREPL tmp = *a; + *a = *b; + *b = tmp; +} +static inline void php_strtr_fix_heap(struct hs_data *data, size_t i) +{ + size_t li = HS_LEFT(i), + ri = HS_RIGHT(i), + largei; + if (li < data->heapel && HS_CMP_CALL(data, li, i) > 0) { + largei = li; + } else { + largei = i; + } + if (ri < data->heapel && HS_CMP_CALL(data, ri, largei) > 0) { + largei = ri; + } + if (largei != i) { + php_strtr_swap(HS_OFF(data, i), HS_OFF(data, largei)); + php_strtr_fix_heap(data, largei); + } +} +static inline void php_strtr_build_heap(struct hs_data *data) +{ + size_t i; + for (i = data->nel / 2; i > 0; i--) { + php_strtr_fix_heap(data, i - 1); + } +} +static inline void php_strtr_heapsort(PATNREPL *arr, size_t nel, PPRES *res) +{ + struct hs_data data = { arr, nel, nel, res }; + size_t i; + php_strtr_build_heap(&data); + for (i = nel; i > 1; i--) { + php_strtr_swap(arr, HS_OFF(&data, i - 1)); + data.heapel--; + php_strtr_fix_heap(&data, 0); + } +} +/* }}} */ +/* {{{ php_strtr_free_strp */ +static void php_strtr_free_strp(void *strp) +{ + STR_FREE(*(char**)strp); +} +/* }}} */ +/* {{{ php_strtr_array_prepare_repls */ +static PATNREPL *php_strtr_array_prepare_repls(int slen, HashTable *pats, zend_llist **allocs, int *outsize) +{ + PATNREPL *patterns; + HashPosition hpos; + zval **entry; + int num_pats = zend_hash_num_elements(pats), + i; + + patterns = safe_emalloc(num_pats, sizeof(*patterns), 0); + *allocs = emalloc(sizeof **allocs); + zend_llist_init(*allocs, sizeof(void*), &php_strtr_free_strp, 0); + + for (i = 0, zend_hash_internal_pointer_reset_ex(pats, &hpos); + zend_hash_get_current_data_ex(pats, (void **)&entry, &hpos) == SUCCESS; + zend_hash_move_forward_ex(pats, &hpos)) { + char *string_key; + uint string_key_len; + ulong num_key; + zval *tzv = NULL; + + switch (zend_hash_get_current_key_ex(pats, &string_key, &string_key_len, &num_key, 0, &hpos)) { + case HASH_KEY_IS_LONG: + string_key_len = 1 + zend_spprintf(&string_key, 0, "%ld", (long)num_key); + zend_llist_add_element(*allocs, &string_key); + /* break missing intentionally */ + + case HASH_KEY_IS_STRING: + string_key_len--; /* exclude final '\0' */ + if (string_key_len == 0) { /* empty string given as pattern */ + efree(patterns); + zend_llist_destroy(*allocs); + efree(*allocs); + *allocs = NULL; + return NULL; + } + if (string_key_len > slen) { /* this pattern can never match */ + continue; + } - convert_to_string(&ctmp); - len = Z_STRLEN(ctmp); - zend_hash_add(&tmp_hash, Z_STRVAL(ctmp), len+1, entry, sizeof(zval*), NULL); - zval_dtor(&ctmp); + if (Z_TYPE_PP(entry) != IS_STRING) { + tzv = *entry; + zval_addref_p(tzv); + SEPARATE_ZVAL(&tzv); + convert_to_string(tzv); + entry = &tzv; + zend_llist_add_element(*allocs, &Z_STRVAL_PP(entry)); + } - if (len > maxlen) { - maxlen = len; - } - if (len < minlen) { - minlen = len; - } - break; + S(&patterns[i].pat) = string_key; + L(&patterns[i].pat) = string_key_len; + S(&patterns[i].repl) = Z_STRVAL_PP(entry); + L(&patterns[i].repl) = Z_STRLEN_PP(entry); + i++; + + if (tzv) { + efree(tzv); + } } - zend_hash_move_forward_ex(hash, &hpos); } - key = emalloc(maxlen+1); - pos = 0; + *outsize = i; + return patterns; +} +/* }}} */ + +/* {{{ PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, int B, int Bp) */ +static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, int B, int Bp) +{ + int i; + PPRES *res = emalloc(sizeof *res); - while (pos < slen) { - if ((pos + maxlen) > slen) { - maxlen = slen - pos; + res->m = (STRLEN)-1; + for (i = 0; i < patnum; i++) { + if (L(&patterns[i].pat) < res->m) { + res->m = L(&patterns[i].pat); } + } + assert(res->m > 0); + res->B = B = MIN(B, res->m); + res->Bp = Bp = MIN(Bp, res->m); - found = 0; - memcpy(key, str+pos, maxlen); - - for (len = maxlen; len >= minlen; len--) { - key[len] = 0; + res->shift = safe_emalloc(SHIFT_TAB_SIZE, sizeof(*res->shift->entries), sizeof(*res->shift)); + res->shift->table_mask = SHIFT_TAB_SIZE - 1; + php_strtr_populate_shift(patterns, patnum, B, res->m, res->shift); - if (zend_hash_find(&tmp_hash, key, len+1, (void**)&trans) == SUCCESS) { - char *tval; - int tlen; - zval tmp; + res->hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res->hash->entries), sizeof(*res->hash)); + res->hash->table_mask = HASH_TAB_SIZE - 1; - if (Z_TYPE_PP(trans) != IS_STRING) { - tmp = **trans; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - tval = Z_STRVAL(tmp); - tlen = Z_STRLEN(tmp); - } else { - tval = Z_STRVAL_PP(trans); - tlen = Z_STRLEN_PP(trans); - } + res->patterns = safe_emalloc(patnum, sizeof(*res->patterns), 0); + memcpy(res->patterns, patterns, sizeof(*patterns) * patnum); + php_strtr_heapsort(res->patterns, patnum, res); - smart_str_appendl(&result, tval, tlen); - pos += len; - found = 1; + res->prefix = safe_emalloc(patnum, sizeof(*res->prefix), 0); + for (i = 0; i < patnum; i++) { + res->prefix[i] = php_strtr_hash(S(&res->patterns[i].pat), Bp); + } - if (Z_TYPE_PP(trans) != IS_STRING) { - zval_dtor(&tmp); - } - break; + /* Initialize the rest of ->hash */ + for (i = 0; i < HASH_TAB_SIZE; i++) { + res->hash->entries[i] = -1; + } + { + HASH last_h = -1; /* assumes not all bits are used in res->hash */ + /* res->patterns is already ordered by hash. + * Make res->hash->entries[h] de index of the first pattern in + * res->patterns that has hash h */ + for (i = 0; i < patnum; i++) { + HASH h = php_strtr_hash(&S(&res->patterns[i].pat)[res->m - res->B], res->B) + & res->hash->table_mask; + if (h != last_h) { + res->hash->entries[h] = i; + last_h = h; } } + } + res->hash->entries[HASH_TAB_SIZE] = patnum; /* OK, we effectively allocated SIZE+1 */ + for (i = HASH_TAB_SIZE - 1; i >= 0; i--) { + if (res->hash->entries[i] == -1) { + res->hash->entries[i] = res->hash->entries[i + 1]; + } + } + + res->patnum = patnum; - if (! found) { - smart_str_appendc(&result, str[pos++]); + return res; +} +/* }}} */ +/* {{{ php_strtr_array_destroy_ppres(PPRES *d) */ +static void php_strtr_array_destroy_ppres(PPRES *d) +{ + efree(d->shift); + efree(d->hash); + efree(d->prefix); + efree(d->patterns); + efree(d); +} +/* }}} */ + +/* {{{ php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) */ +static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) +{ + STRLEN pos = 0, + nextwpos = 0, + lastpos = L(text) - d->m; + smart_str result = {0}; + + while (pos <= lastpos) { + HASH h = php_strtr_hash(&S(text)[pos + d->m - d->B], d->B) & d->shift->table_mask; + STRLEN shift = d->shift->entries[h]; + + if (shift > 0) { + pos += shift; + } else { + HASH h2 = h & d->hash->table_mask, + prefix_h = php_strtr_hash(&S(text)[pos], d->Bp); + + int offset_start = d->hash->entries[h2], + offset_end = d->hash->entries[h2 + 1], /* exclusive */ + i = 0; + + for (i = offset_start; i < offset_end; i++) { + PATNREPL *pnr; + if (d->prefix[i] != prefix_h) + continue; + + pnr = &d->patterns[i]; + if (L(&pnr->pat) > L(text) - pos || + memcmp(S(&pnr->pat), &S(text)[pos], L(&pnr->pat)) != 0) + continue; + + smart_str_appendl(&result, &S(text)[nextwpos], pos - nextwpos); + smart_str_appendl(&result, S(&pnr->repl), L(&pnr->repl)); + pos += L(&pnr->pat); + nextwpos = pos; + goto end_outer_loop; + } + + pos++; +end_outer_loop: ; } } - efree(key); - zend_hash_destroy(&tmp_hash); - smart_str_0(&result); - RETVAL_STRINGL(result.c, result.len, 0); + smart_str_appendl(&result, &S(text)[nextwpos], L(text) - nextwpos); + + if (result.c != NULL) { + smart_str_0(&result); + RETVAL_STRINGL(result.c, result.len, 0); + } else { + RETURN_EMPTY_STRING(); + } +} +/* }}} */ + +/* {{{ php_strtr_array */ +static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *pats) +{ + PPRES *data; + STR text; + PATNREPL *patterns; + int patterns_len; + zend_llist *allocs; + + S(&text) = str; + L(&text) = slen; + + patterns = php_strtr_array_prepare_repls(slen, pats, &allocs, &patterns_len); + if (patterns == NULL) { + RETURN_FALSE; + } + data = php_strtr_array_prepare(&text, patterns, patterns_len, 2, 2); + efree(patterns); + php_strtr_array_do_repl(&text, data, return_value); + php_strtr_array_destroy_ppres(data); + zend_llist_destroy(allocs); + efree(allocs); } /* }}} */ diff --git a/ext/standard/tests/image/getimagesize.phpt b/ext/standard/tests/image/getimagesize.phpt index ab79c9c76..6cd8275e0 100644 --- a/ext/standard/tests/image/getimagesize.phpt +++ b/ext/standard/tests/image/getimagesize.phpt @@ -23,7 +23,22 @@ GetImageSize() var_dump($result); ?> --EXPECT-- -array(11) { +array(12) { + ["test1bpix.bmp"]=> + array(6) { + [0]=> + int(500) + [1]=> + int(345) + [2]=> + int(6) + [3]=> + string(24) "width="500" height="345"" + ["bits"]=> + int(32) + ["mime"]=> + string(14) "image/x-ms-bmp" + } ["test1pix.bmp"]=> array(6) { [0]=> diff --git a/ext/standard/tests/image/image_type_to_mime_type.phpt b/ext/standard/tests/image/image_type_to_mime_type.phpt index 5d94a6fe5..d83ab8d14 100644 --- a/ext/standard/tests/image/image_type_to_mime_type.phpt +++ b/ext/standard/tests/image/image_type_to_mime_type.phpt @@ -1,8 +1,8 @@ --TEST-- image_type_to_mime_type() --SKIPIF-- -<?php - if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); +<?php + if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available'); require_once('skipif_imagetype.inc'); ?> --FILE-- @@ -25,7 +25,9 @@ image_type_to_mime_type() var_dump($result); ?> --EXPECT-- -array(11) { +array(12) { + ["test1bpix.bmp"]=> + string(14) "image/x-ms-bmp" ["test1pix.bmp"]=> string(14) "image/x-ms-bmp" ["test1pix.jp2"]=> @@ -48,4 +50,4 @@ array(11) { string(29) "application/x-shockwave-flash" ["test4pix.tif"]=> string(10) "image/tiff" -}
\ No newline at end of file +} diff --git a/ext/standard/tests/image/test1bpix.bmp b/ext/standard/tests/image/test1bpix.bmp Binary files differnew file mode 100644 index 000000000..5522e503d --- /dev/null +++ b/ext/standard/tests/image/test1bpix.bmp diff --git a/ext/standard/tests/strings/bug63943.phpt b/ext/standard/tests/strings/bug63943.phpt new file mode 100644 index 000000000..6018879b2 --- /dev/null +++ b/ext/standard/tests/strings/bug63943.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #63943 (Bad warning text from strpos() on empty needle) +--FILE-- +<?php +strpos("lllllll", ''); +?> +--EXPECTF-- +Warning: strpos(): Empty needle in %sbug63943.php on line %d diff --git a/ext/standard/tests/strings/get_html_translation_table_basic10.phpt b/ext/standard/tests/strings/get_html_translation_table_basic10.phpt new file mode 100644 index 000000000..a5a356885 --- /dev/null +++ b/ext/standard/tests/strings/get_html_translation_table_basic10.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test get_html_translation_table() function: htmlentities/HTML 4/ISO-8859-1 (bug #64011) +--FILE-- +<?php + +function so($a,$b) { return ord($a) - ord($b); } + +$table = HTML_ENTITIES; +$tt = get_html_translation_table($table, ENT_COMPAT, "ISO-8859-1"); +uksort( $tt, 'so' ); +var_dump( count($tt) ); +print_r( $tt ); +echo "Done\n"; + +?> +--EXPECT-- +int(100) +Array +( + ["] => " + [&] => & + [<] => < + [>] => > + [ ] => + [¡] => ¡ + [¢] => ¢ + [£] => £ + [¤] => ¤ + [¥] => ¥ + [¦] => ¦ + [§] => § + [¨] => ¨ + [©] => © + [ª] => ª + [«] => « + [¬] => ¬ + [] => ­ + [®] => ® + [¯] => ¯ + [°] => ° + [±] => ± + [²] => ² + [³] => ³ + [´] => ´ + [µ] => µ + [¶] => ¶ + [·] => · + [¸] => ¸ + [¹] => ¹ + [º] => º + [»] => » + [¼] => ¼ + [½] => ½ + [¾] => ¾ + [¿] => ¿ + [À] => À + [Á] => Á + [Â] => Â + [Ã] => Ã + [Ä] => Ä + [Å] => Å + [Æ] => Æ + [Ç] => Ç + [È] => È + [É] => É + [Ê] => Ê + [Ë] => Ë + [Ì] => Ì + [Í] => Í + [Î] => Î + [Ï] => Ï + [Ð] => Ð + [Ñ] => Ñ + [Ò] => Ò + [Ó] => Ó + [Ô] => Ô + [Õ] => Õ + [Ö] => Ö + [×] => × + [Ø] => Ø + [Ù] => Ù + [Ú] => Ú + [Û] => Û + [Ü] => Ü + [Ý] => Ý + [Þ] => Þ + [ß] => ß + [à] => à + [á] => á + [â] => â + [ã] => ã + [ä] => ä + [å] => å + [æ] => æ + [ç] => ç + [è] => è + [é] => é + [ê] => ê + [ë] => ë + [ì] => ì + [í] => í + [î] => î + [ï] => ï + [ð] => ð + [ñ] => ñ + [ò] => ò + [ó] => ó + [ô] => ô + [õ] => õ + [ö] => ö + [÷] => ÷ + [ø] => ø + [ù] => ù + [ú] => ú + [û] => û + [ü] => ü + [ý] => ý + [þ] => þ + [ÿ] => ÿ +) +Done diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt Binary files differindex 706ddfdcb..9b44584ee 100644 --- a/ext/standard/tests/strings/strpos.phpt +++ b/ext/standard/tests/strings/strpos.phpt diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index 960e8092a..7591ca73e 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Wed Nov 9 19:37:48 2011 */ +/* Generated by re2c 0.13.5 on Mon Jan 21 11:34:03 2013 */ /* +----------------------------------------------------------------------+ | PHP Version 5 | diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index e54449a78..204995783 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -678,10 +678,13 @@ object ":" uiv ":" ["] { do { /* Try to find class directly */ + BG(serialize_lock) = 1; if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) { + BG(serialize_lock) = 0; ce = *pce; break; } + BG(serialize_lock) = 0; /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { @@ -696,7 +699,9 @@ object ":" uiv ":" ["] { args[0] = &arg_func_name; MAKE_STD_ZVAL(arg_func_name); ZVAL_STRING(arg_func_name, class_name, 1); + BG(serialize_lock) = 1; if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { + BG(serialize_lock) = 0; php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val); incomplete_class = 1; ce = PHP_IC_ENTRY; @@ -704,6 +709,7 @@ object ":" uiv ":" ["] { zval_ptr_dtor(&arg_func_name); break; } + BG(serialize_lock) = 0; if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } |
