php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12368 Regexp limit the string size
Submitted: 2001-07-25 11:51 UTC Modified: 2001-11-10 15:28 UTC
From: stefanbocskai at hotmail dot com Assigned:
Status: Closed Package: Regexps related
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
 [2001-07-25 11:51 UTC] stefanbocskai at hotmail dot com
hi

I used the regexp functions (ereg and eregi) to split a file in blocks, the delimiters are somthing like:
<!-- BEGIN BLOCK: main -->
<!-- END BLOCK: main -->

but the split operation failt if the file size is bigger then (aproximative value) 11k

So, this is a bug or this was already specified in some place?

Stefan
 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-30 10:54 UTC] sander@php.net
Unable to reproduce, see the following code:
<?php
$string = str_repeat("0", 10000)."abc".str_repeat("0", 10000);
echo ereg("abc", $string)?"true":"false";
?>
Returns true.

Can you post a snippet of your code?
 [2001-08-30 12:32 UTC] stefanbocskai at hotmail dot com
Hi and thanks for your interrest!

Here is an example to ilustrate my problem! I'm not sure if is a memory problem or a bug.

I copyed and adapted a part of my source:

<?php
$LEN=5000;   //-- is not working
//$LEN=1000; //-- is working

// creating a long string containg a sub "block"
$BlockTemplate=str_repeat("0", $LEN)."<!-- BEGIN BLOCK: abc -->".str_repeat("I", $LEN)."<!-- END BLOCK: abc -->".str_repeat("0", $LEN);
$BLOCKS=array();

function _createChildren_(){
global $BlockTemplate,$BLOCKS; 
$part="[a-z,0-9,\_]*";
$_start_tag_ = "<!--";
$_end_tag_  = "-->";
$_begin_block_ = "BEGIN[[:blank:]]*BLOCK:";
$_end_block_  = "END[[:blank:]]*BLOCK:";

// creating pattern ...
$patern_begin 	= $_start_tag_."[[:blank:]]*".$_begin_block_."[[:blank:]]*(".$part.")[[:blank:]]*".$_end_tag_;
$patern_end1 	= $_start_tag_."[[:blank:]]*".$_end_block_."[[:blank:]]*";
$patern_end2    = "[[:blank:]]*".$_end_tag_;

	while ((eregi("(".$patern_begin.")(.*)$",$BlockTemplate,$res))&&(eregi("^((.*)".$patern_end1.$res[2].$patern_end2.")", $res[3], $res2))){
		// 	now $res2[2] is the content of the new block
		//		and $res[2] is the name ...
		// colecting in $BLOCKS the block contain if was found
		$BLOCKS[$res[2]] = $res2[2]; 
		$patern = $res[1].$res2[1];
		$BlockTemplate = str_replace($patern,"{ABC.".$res[2]."}", $BlockTemplate);
	}//while
	
}

//the following will extract all chlidren block from text ...
_createChildren_();

//if the block was found will be printed
echo "--".$BLOCKS["abc"]."--";


?>


This problem apears only on php4.0.4pl1

Thanks for your collaboration!
Stefan
 [2001-11-10 15:28 UTC] sander@php.net
Works fine for me with 4.0.6. It prints out a whole bunch of IIIII's. Try upgrading to 4.0.6 and reopen this report if the problem still occurs.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 13:01:35 2019 UTC