Browse files

Merge pull request #224 from fruit/preg_quote

Use preg_quote() to escape text before inserting into regexp
  • Loading branch information...
2 parents c577cc7 + dc8c284 commit d8c17cd427ff345ebc13193ebbf3a4dee49e44ff @guilhermeblanco guilhermeblanco committed Nov 20, 2012
View
2 lib/Doctrine/Common/Annotations/PhpParser.php
@@ -51,7 +51,7 @@ public function parseClass(\ReflectionClass $class)
return array();
}
- $namespace = str_replace('\\', '\\\\', $class->getNamespaceName());
+ $namespace = preg_quote($class->getNamespaceName());
$content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
$tokenizer = new TokenParser('<?php ' . $content);
View
2 lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php
@@ -184,7 +184,7 @@ public function getAllClassNames()
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
),
- '/^.+' . str_replace('.', '\.', $this->fileExtension) . '$/i',
+ '/^.+' . preg_quote($this->fileExtension) . '$/i',
\RecursiveRegexIterator::GET_MATCH
);

0 comments on commit d8c17cd

Please sign in to comment.