tingobol / yii-rights

Automatically exported from code.google.com/p/yii-rights
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: missing ) at offset 19 #55

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I go to roles...
clic to update a role
and enter a description
clic on SAVE.

The system exclaim:
preg_match() [<a href='function.preg-match'>function.preg-match</a>]: 
Compilation failed: missing ) at offset 19 

C:\Program 
Files\Zend\Apache2\htdocs\fovis\protected\modules\rights\components\RAuthorizer.
php(448)
448             if( preg_match('/'.$f.'\ *\({1}/', $code)>0 )

Original issue reported on code.google.com by *directo...@sistemasycontroles.net on 23 Jun 2011 at 9:39

GoogleCodeExporter commented 9 years ago
me too.

My development environment is windows, it runs very well.
But when I deployed my application to my server(which os is centos), I met the 
same error. "preg_match() [<a 
href='function.preg-match'>function.preg-match</a>]: Compilation failed: 
missing terminating ] for character class at offset 30 "

the stack trace is shown in the attached file.

It seems that the error is caused by the data parameter. In RightModule.php, 
the enableBizRuleData attribute is set to false, so in the update form the data 
input doesn't display.  Is that the reason?

Original comment by li...@ruyi.com on 22 Jul 2011 at 2:13

Attachments:

GoogleCodeExporter commented 9 years ago
eng - when using the Zend, the function  preg_match('/'.$f.'\ *\({1}/', $code)  
  passed names like uer1qc[<lm*ujhb0
which is why the error occurs.
you must either exclude such functions from scanning, or escape special 
characters using the preg_quote.

foreach( $functions as $f ) 
    if( preg_match('/'.preg_quote($f).'\ *\({1}/', $code)>0 )
        return null; // Function call found, not safe for eval.

rus - это потому что Вы используете Zend и он 
создает функции с именами в виде 
кракозяблов. При подстановке в preg_match их 
имен возникает ошибка. Чтобы этого 
избежать, необходимо экранировать эти 
названия с помощью preg_quote($f, "/")

Original comment by vasilyev...@gmail.com on 30 Nov 2011 at 5:29

GoogleCodeExporter commented 9 years ago
I was still having error, even after make the changes proposed by vasilyev.
If you have the same situation, try to add a delimiter to  preg_quote:

Before:
if( preg_match('/'.preg_quote($f).'\ *\({1}/', $code)>0 )

After:
if( preg_match('/'.preg_quote($f, '/').'\ *\({1}/', $code)>0 )

Now I have no more errors.

Original comment by central....@gmail.com on 9 Apr 2012 at 9:03