From d0ed5b984c2eb5a6530f78b2e478cfcd10e15de8 Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Tue, 15 Jan 2002 15:40:31 +0000 Subject: [PATCH] - Fixed a bug with matching string containing null bytes. --- NEWS | 2 ++ ext/pcre/php_pcre.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index dc63126c13..c46d63dba1 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ PHP 4 NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 200?, Version 4.2.0-dev +- Fixed a bug in preg_match()/preg_match_all() when matching strings containing + null bytes. (Andrei) - Added xpath_register_ns() function. It makes possible to issue XPath queries with namespaces like for example: "//namespace:sampletag" (Chris Jarecki) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 47c4f082bd..7d588cc10b 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -440,7 +440,8 @@ static void php_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) if (subpats_order_val == PREG_PATTERN_ORDER) { /* For each subpattern, insert it into the appropriate array. */ for (i = 0; i < count; i++) { - add_next_index_string(match_sets[i], (char *)stringlist[i], 1); + add_next_index_stringl(match_sets[i], (char *)stringlist[i], + offsets[(i<<1)+1] - offsets[i<<1], 1); } /* * If the number of captured subpatterns on this run is @@ -460,7 +461,8 @@ static void php_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* Add all the subpatterns to it */ for (i = 0; i < count; i++) { - add_next_index_string(result_set, (char *)stringlist[i], 1); + add_next_index_stringl(result_set, (char *)stringlist[i], + offsets[(i<<1)+1] - offsets[i<<1], 1); } /* And add it to the output array */ zend_hash_next_index_insert(Z_ARRVAL_PP(subpats), &result_set, @@ -470,7 +472,8 @@ static void php_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) else { /* single pattern matching */ /* For each subpattern, insert it into the subpatterns array. */ for (i = 0; i < count; i++) { - add_next_index_string((*subpats), (char *)stringlist[i], 1); + add_next_index_stringl((*subpats), (char *)stringlist[i], + offsets[(i<<1)+1] - offsets[i<<1], 1); } } -- 2.50.1