Commit 67b4eb8 1 parent a4d3adf commit 67b4eb8 Copy full SHA for 67b4eb8
File tree 1 file changed +28
-0
lines changed
components/content/src/front_matter
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,14 @@ impl PageFrontMatter {
103
103
104
104
f. date_to_datetime ( ) ;
105
105
106
+ for ( _, terms) in & f. taxonomies {
107
+ for term in terms {
108
+ if term. trim ( ) . is_empty ( ) {
109
+ bail ! ( "A taxonomy term cannot be an empty string" ) ;
110
+ }
111
+ }
112
+ }
113
+
106
114
if let Some ( ref date) = f. date {
107
115
if f. datetime . is_none ( ) {
108
116
bail ! ( "`date` could not be parsed: {}." , date) ;
@@ -474,4 +482,24 @@ taxonomies:
474
482
assert_eq ! ( res2. taxonomies[ "categories" ] , vec![ "Dev" ] ) ;
475
483
assert_eq ! ( res2. taxonomies[ "tags" ] , vec![ "Rust" , "JavaScript" ] ) ;
476
484
}
485
+
486
+ #[ test_case( & RawFrontMatter :: Toml ( r#"
487
+ title = "Hello World"
488
+
489
+ [taxonomies]
490
+ tags = [""]
491
+ "# ) ; "toml" ) ]
492
+ #[ test_case( & RawFrontMatter :: Yaml ( r#"
493
+ title: Hello World
494
+
495
+ taxonomies:
496
+ tags:
497
+ -
498
+ "# ) ; "yaml" ) ]
499
+ fn errors_on_empty_taxonomy_term ( content : & RawFrontMatter ) {
500
+ // https://github.com/getzola/zola/issues/2085
501
+ let res = PageFrontMatter :: parse ( content) ;
502
+ println ! ( "{:?}" , res) ;
503
+ assert ! ( res. is_err( ) ) ;
504
+ }
477
505
}
You can’t perform that action at this time.
0 commit comments