فهرست منبع

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

Justin Hileman 15 سال پیش
والد
کامیت
fe91be1fb1
1فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  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, '/')
 		);
 	}