PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | assets/lib/Mustache/Loader/FilesystemLoader.php +18 -7 2.0.24.0.3 View file →
@@ -2,9 +2,9 @@
2 2
3 3 /*
4 4 * This file is part of Mustache.php.
5 5 *
6 - * (c) 2012 Justin Hileman
6 + * (c) 2010-2017 Justin Hileman
7 7 *
8 8 * For the full copyright and license information, please view the LICENSE
9 9 * file that was distributed with this source code.
10 10 */
@@ -39,11 +39,11 @@
39 39 * // The filename extension used for Mustache templates. Defaults to '.mustache'
40 40 * 'extension' => '.ms',
41 41 * );
42 42 *
43 - * @throws Mustache_Exception_RuntimeException if $baseDir does not exist.
43 + * @throws Mustache_Exception_RuntimeException if $baseDir does not exist
44 44 *
45 - * @param string $baseDir Base directory containing Mustache template files.
45 + * @param string $baseDir Base directory containing Mustache template files
46 46 * @param array $options Array of Loader options (default: array())
47 47 */
48 48 public function __construct($baseDir, array $options = array())
49 49 {
@@ -48,13 +48,13 @@
48 48 public function __construct($baseDir, array $options = array())
49 49 {
50 50 $this->baseDir = $baseDir;
51 51
52 - if (strpos($this->baseDir, '://') === -1) {
52 + if (strpos($this->baseDir, '://') === false) {
53 53 $this->baseDir = realpath($this->baseDir);
54 54 }
55 55
56 - if (!is_dir($this->baseDir)) {
56 + if ($this->shouldCheckPath() && !is_dir($this->baseDir)) {
57 57 throw new Mustache_Exception_RuntimeException(sprintf('FilesystemLoader baseDir must be a directory: %s', $baseDir));
58 58 }
59 59
60 60 if (array_key_exists('extension', $options)) {
@@ -87,9 +87,9 @@
87 87
88 88 /**
89 89 * Helper function for loading a Mustache file by name.
90 90 *
91 - * @throws Mustache_Exception_UnknownTemplateException If a template file is not found.
91 + * @throws Mustache_Exception_UnknownTemplateException If a template file is not found
92 92 *
93 93 * @param string $name
94 94 *
95 95 * @return string Mustache Template source
@@ -97,9 +97,9 @@
97 97 protected function loadFile($name)
98 98 {
99 99 $fileName = $this->getFileName($name);
100 100
101 - if (!file_exists($fileName)) {
101 + if ($this->shouldCheckPath() && !file_exists($fileName)) {
102 102 throw new Mustache_Exception_UnknownTemplateException($name);
103 103 }
104 104
105 105 return file_get_contents($fileName);
@@ -119,6 +119,17 @@
119 119 $fileName .= $this->extension;
120 120 }
121 121
122 122 return $fileName;
123 + }
124 +
125 + /**
126 + * Only check if baseDir is a directory and requested templates are files if
127 + * baseDir is using the filesystem stream wrapper.
128 + *
129 + * @return bool Whether to check `is_dir` and `file_exists`
130 + */
131 + protected function shouldCheckPath()
132 + {
133 + return strpos($this->baseDir, '://') === false || strpos($this->baseDir, 'file://') === 0;
123 134 }
124 135 }