@@ -181,7 +181,16 @@ List<String> tags() {
181181 var t = node .get ("tags" );
182182 if (t == null || !t .isArray ()) return List .of ();
183183 var tagList = new ArrayList <String >();
184- t .forEach (n -> tagList .add (n .asText ()));
184+ t .forEach (n -> {
185+ var tag = n .asText ().strip ();
186+ if (!tag .matches ("[a-z0-9]+(?:-[a-z0-9]+)*" )) {
187+ throw new IllegalArgumentException ("Invalid tag slug \" " + tag + "\" in " + key ());
188+ }
189+ if (!TAG_DISPLAY .containsKey (tag )) {
190+ throw new IllegalArgumentException ("Unknown tag \" " + tag + "\" in " + key () + " (missing from " + TAGS_FILE + ")" );
191+ }
192+ tagList .add (tag );
193+ });
185194 return tagList ;
186195 }
187196}
@@ -392,7 +401,7 @@ String renderIndexCard(String tpl, Snippet s, String locale, Map<String, String>
392401 var cardHref = locale .equals ("en" )
393402 ? "/%s/%s.html" .formatted (s .category (), s .slug ())
394403 : "/%s/%s/%s.html" .formatted (locale , s .category (), s .slug ());
395- var tagsValue = String .join (" " , s .tags ());
404+ var tagsValue = escape ( String .join (" " , s .tags () ));
396405 return replaceTokens (tpl , Map .ofEntries (
397406 Map .entry ("category" , s .category ()), Map .entry ("slug" , s .slug ()),
398407 Map .entry ("catDisplay" , s .catDisplay ()), Map .entry ("title" , escape (s .title ())),
0 commit comments