22
33namespace Statamic \Providers ;
44
5+ use Illuminate \Contracts \Foundation \Application ;
56use Illuminate \Support \Facades \Blade ;
67use Illuminate \Support \Facades \View as ViewFactory ;
78use Illuminate \Support \ServiceProvider ;
@@ -107,71 +108,135 @@ private function registerAntlers()
107108 'trans:* ' ,
108109 'trans_choice:* ' ,
109110 'widont:* ' ,
111+ ...$ this ->getAppTagPatternsForContentAllowlist ($ app ),
110112 ]);
113+
111114 $ runtimeConfig ->allowedContentModifiers = config ('statamic.antlers.allowedContentModifiers ' , [
112115 'add_query_param ' ,
113116 'add_slashes ' ,
117+ 'alias ' ,
118+ 'ampersand_list ' ,
114119 'ascii ' ,
115120 'at ' ,
121+ 'backspace ' ,
116122 'background_position ' ,
117123 'bool_string ' ,
118124 'camelize ' ,
119125 'cdata ' ,
120126 'ceil ' ,
127+ 'chunk ' ,
128+ 'classes ' ,
129+ 'collapse ' ,
121130 'collapse_whitespace ' ,
131+ 'contains_any ' ,
132+ 'count ' ,
122133 'count_substring ' ,
123134 'dashify ' ,
135+ 'days_ago ' ,
124136 'decode ' ,
125137 'deslugify ' ,
138+ 'diff_for_humans ' ,
126139 'divide ' ,
140+ 'dl ' ,
141+ 'embed_url ' ,
127142 'ends_with ' ,
128143 'ensure_left ' ,
129144 'ensure_right ' ,
130145 'entities ' ,
146+ 'excerpt ' ,
131147 'explode ' ,
132148 'extension ' ,
149+ 'favicon ' ,
150+ 'filter_empty ' ,
151+ 'first ' ,
152+ 'flatten ' ,
153+ 'flip ' ,
133154 'floor ' ,
134155 'format ' ,
135156 'format_number ' ,
136157 'format_translated ' ,
158+ 'full_urls ' ,
137159 'has_lower_case ' ,
138160 'has_upper_case ' ,
139161 'headline ' ,
140162 'hex_to_rgb ' ,
163+ 'hours_ago ' ,
141164 'insert ' ,
142165 'is_alpha ' ,
143166 'is_alphanumeric ' ,
167+ 'is_array ' ,
144168 'is_blank ' ,
145169 'is_email ' ,
170+ 'is_embeddable ' ,
171+ 'is_empty ' ,
146172 'is_external_url ' ,
173+ 'is_future ' ,
174+ 'is_iterable ' ,
147175 'is_json ' ,
176+ 'is_leap_year ' ,
148177 'is_lowercase ' ,
149178 'is_numeric ' ,
179+ 'is_past ' ,
180+ 'is_today ' ,
181+ 'is_tomorrow ' ,
150182 'is_uppercase ' ,
151183 'is_url ' ,
184+ 'is_weekday ' ,
185+ 'is_weekend ' ,
186+ 'is_yesterday ' ,
187+ 'iso_format ' ,
152188 'join ' ,
189+ 'key_by ' ,
190+ 'keys ' ,
153191 'kebab ' ,
192+ 'last ' ,
154193 'lcfirst ' ,
194+ 'length ' ,
195+ 'limit ' ,
155196 'localize ' ,
156- 'upper ' ,
157197 'lower ' ,
198+ 'markdown ' ,
158199 'md5 ' ,
200+ 'minutes_ago ' ,
159201 'mod ' ,
202+ 'modify_date ' ,
203+ 'months_ago ' ,
160204 'multiply ' ,
205+ 'nl2br ' ,
161206 'obfuscate ' ,
162207 'obfuscate_email ' ,
208+ 'offset ' ,
209+ 'ol ' ,
210+ 'option_list ' ,
163211 'parse_url ' ,
164212 'pathinfo ' ,
213+ 'pluck ' ,
214+ 'random ' ,
165215 'rawurlencode ' ,
216+ 'read_time ' ,
217+ 'relative ' ,
166218 'remove_left ' ,
167219 'remove_query_param ' ,
168220 'remove_right ' ,
169221 'replace ' ,
222+ 'resolve ' ,
223+ 'reverse ' ,
170224 'round ' ,
171225 'safe_truncate ' ,
172226 'sanitize ' ,
227+ 'scope ' ,
228+ 'seconds_ago ' ,
229+ 'select ' ,
230+ 'sentence_list ' ,
231+ 'set_query_param ' ,
232+ 'shuffle ' ,
233+ 'singular ' ,
173234 'slugify ' ,
235+ 'smartypants ' ,
174236 'snake ' ,
237+ 'sort ' ,
238+ 'spaceless ' ,
239+ 'split ' ,
175240 'starts_with ' ,
176241 'str_pad ' ,
177242 'str_pad_both ' ,
@@ -182,18 +247,38 @@ private function registerAntlers()
182247 'subtract ' ,
183248 'substr ' ,
184249 'sum ' ,
250+ 'surround ' ,
185251 'swap_case ' ,
252+ 'table ' ,
253+ 'tidy ' ,
254+ 'timestamp ' ,
255+ 'timezone ' ,
186256 'title ' ,
187257 'to_bool ' ,
258+ 'to_qs ' ,
259+ 'to_spaces ' ,
260+ 'to_tabs ' ,
188261 'to_string ' ,
189262 'trans ' ,
190263 'trans_choice ' ,
264+ 'trackable_embed_url ' ,
191265 'trim ' ,
192266 'truncate ' ,
267+ 'type_of ' ,
193268 'ucfirst ' ,
269+ 'underscored ' ,
270+ 'unique ' ,
271+ 'upper ' ,
194272 'urldecode ' ,
195273 'urlencode ' ,
274+ 'values ' ,
275+ 'weeks_ago ' ,
276+ 'where ' ,
277+ 'where_in ' ,
196278 'widont ' ,
279+ 'word_count ' ,
280+ 'years_ago ' ,
281+ ...$ this ->getAppModifierHandlesForContentAllowlist ($ app ),
197282 ]);
198283 $ runtimeConfig ->allowPhpInUserContent = config ('statamic.antlers.allowPhpInContent ' , false );
199284 $ runtimeConfig ->allowMethodsInUserContent = config ('statamic.antlers.allowMethodsInContent ' , false );
@@ -250,6 +335,29 @@ private function registerAntlers()
250335 });
251336 }
252337
338+ private function getAppTagPatternsForContentAllowlist (Application $ app ): array
339+ {
340+ $ namespace = $ app ->getNamespace ().'Tags \\' ;
341+
342+ return collect ($ app ->make ('statamic.tags ' ))
343+ ->filter (fn ($ binding ) => is_string ($ binding ) && str_starts_with ($ binding , $ namespace ))
344+ ->keys ()
345+ ->flatMap (fn ($ handle ) => [$ handle , $ handle .':* ' ])
346+ ->values ()
347+ ->all ();
348+ }
349+
350+ private function getAppModifierHandlesForContentAllowlist (Application $ app ): array
351+ {
352+ $ namespace = $ app ->getNamespace ().'Modifiers \\' ;
353+
354+ return collect ($ app ->make ('statamic.modifiers ' ))
355+ ->filter (fn ($ binding ) => is_string ($ binding ) && str_starts_with ($ binding , $ namespace ))
356+ ->keys ()
357+ ->values ()
358+ ->all ();
359+ }
360+
253361 public function registerBladeDirectives ()
254362 {
255363 Blade::directive ('tags ' , function ($ expression ) {
0 commit comments