Parcourir la source

Pre-escape tag type constants (saves us from doing it each time the regex strings are prepared)

Justin Hileman il y a 15 ans
Parent
commit
fe91be1fb1
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      Mustache.php

+ 4 - 4
Mustache.php

@@ -258,13 +258,13 @@ class Mustache {
 		return $template;
 	}
 
-	const SECTION_TYPES = '^#/';
+	const SECTION_TYPES = '\^#\/';
 
 	protected function _prepareSectionRegEx($otag, $ctag) {
 		return sprintf(
 			'/(?:(?<=\\n)[ \\t]*)?%s(?<type>[%s])(?<tag_name>.+?)%s\\n?/s',
 			preg_quote($otag, '/'),
-			preg_quote(self::SECTION_TYPES, '/'),
+			self::SECTION_TYPES,
 			preg_quote($ctag, '/')
 		);
 	}
@@ -437,13 +437,13 @@ class Mustache {
 		return (isset($this->_throwsExceptions[$exception]) && $this->_throwsExceptions[$exception]);
 	}
 
-	const TAG_TYPES = '#^/=!<>\\{&';
+	const TAG_TYPES = '#\^\/=!<>\\{&';
 
 	protected function _prepareTagRegex($otag, $ctag) {
 		return sprintf(
 			'/(?<whitespace>(?<=\\n)[ \\t]*)?%s(?<type>[%s]?)(?<tag_name>.+?)(?:\\2|})?%s(?:\\s*(?=\\n))?/s',
 			preg_quote($otag, '/'),
-			preg_quote(self::TAG_TYPES, '/'),
+			self::TAG_TYPES,
 			preg_quote($ctag, '/')
 		);
 	}