- Timestamp:
- 2008-07-23 14:29:20 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
FCKpackager/trunk/_source/includes/fckfunctionprocessor.inc
r2078 r2268 57 57 $processed = $this->_ProcessVars( $processed, $this->_Parameters ) ; 58 58 59 $numVarMatches = preg_match_all( '/\bvar\b\s+([\w_][\w\d_]+)/', $processed, $varsMatches ) ; 59 // Match "var" declarations. 60 $numVarMatches = preg_match_all( '/\bvar\b\s+((?:({(?:(?>[^{}]*)|(?2))*})|[^;])+?)(?=(?:\bin\b)|;)/', $processed, $varsMatches ) ; 60 61 61 62 if ( $numVarMatches > 0 ) … … 65 66 for ( $i = 0 ; $i < $numVarMatches ; $i++ ) 66 67 { 67 $vars[] = $varsMatches[1][$i] ; 68 $varsMatch = $varsMatches[1][$i]; 69 70 // Removed all (...), [...] and {...} blocks from the var 71 // statement to avoid problems with commas inside them. 72 $varsMatch = preg_replace( '/(\((?:(?>[^\(\)]*)|(?1))*\))+/', '', $varsMatch ) ; 73 $varsMatch = preg_replace( '/(\[(?:(?>[^\[\]]*)|(?1))*\])+/', '', $varsMatch ) ; 74 $varsMatch = preg_replace( '/({(?:(?>[^{}]*)|(?1))*})+/', '', $varsMatch ) ; 75 76 $numVarNameMatches = preg_match_all( '/(?:^|,)\s*([^\s=,]+)/', $varsMatch, $varNameMatches ) ; 77 78 for ( $j = 0 ; $j < $numVarNameMatches ; $j++ ) 79 { 80 $vars[] = $varNameMatches[1][$j] ; 81 } 68 82 } 69 83 … … 79 93 { 80 94 if ( strlen( $var) > 1 ) 81 $source = preg_replace( '/(?<!\w|\d|\.)' . $var. '(?!\w|\d)/', $this->_GetVarName(), $source ) ;95 $source = preg_replace( '/(?<!\w|\d|\.)' . preg_quote( $var ) . '(?!\w|\d)/', $this->_GetVarName(), $source ) ; 82 96 } 83 97 … … 95 109 $var = $this->_VarPrefix . $this->_VarChars[ $this->_LastCharIndex++ ] ; 96 110 97 if ( preg_match( '/(?<!\w|\d|\.)' . $var. '(?!\w|\d)/', $this->_Function ) )111 if ( preg_match( '/(?<!\w|\d|\.)' . preg_quote( $var ) . '(?!\w|\d)/', $this->_Function ) ) 98 112 return $this->_GetVarName() ; 99 113 else