@@ -44,7 +44,13 @@ fn main() -> Result<(), Error> {
44
44
}
45
45
46
46
let template = CopyrightTemplate {
47
- in_tree : collected_tree_metadata. files ,
47
+ // in_tree: collected_tree_metadata.files,
48
+ in_tree : Node :: Root {
49
+ children : vec ! [ Node :: File {
50
+ name: "<script>alert(1)</script>" . to_string( ) ,
51
+ license: License { spdx: "" . to_string( ) , copyright: vec![ ] } ,
52
+ } ] ,
53
+ } ,
48
54
dependencies : collected_cargo_metadata,
49
55
} ;
50
56
@@ -62,6 +68,8 @@ struct Metadata {
62
68
}
63
69
64
70
/// Describes one node in our metadata tree
71
+ #[ derive( Template ) ]
72
+ #[ template( path = "node.html" ) ]
65
73
#[ derive( serde:: Deserialize ) ]
66
74
#[ serde( rename_all = "kebab-case" , tag = "type" ) ]
67
75
pub ( crate ) enum Node {
@@ -81,43 +89,43 @@ where
81
89
Ok ( ( ) )
82
90
}
83
91
84
- impl std:: fmt:: Display for Node {
85
- fn fmt ( & self , fmt : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
86
- match self {
87
- Node :: Root { children } => {
88
- if children. len ( ) > 1 {
89
- with_box ( fmt, |f| {
90
- for child in children {
91
- writeln ! ( f, "{child}" ) ?;
92
- }
93
- Ok ( ( ) )
94
- } )
95
- } else {
96
- for child in children {
97
- writeln ! ( fmt, "{child}" ) ?;
98
- }
99
- Ok ( ( ) )
100
- }
101
- }
102
- Node :: Directory { name, children, license } => with_box ( fmt, |f| {
103
- render_tree_license ( std:: iter:: once ( name) , license. as_ref ( ) , f) ?;
104
- if !children. is_empty ( ) {
105
- writeln ! ( f, "<p><b>Exceptions:</b></p>" ) ?;
106
- for child in children {
107
- writeln ! ( f, "{child}" ) ?;
108
- }
109
- }
110
- Ok ( ( ) )
111
- } ) ,
112
- Node :: Group { files, directories, license } => with_box ( fmt, |f| {
113
- render_tree_license ( directories. iter ( ) . chain ( files. iter ( ) ) , Some ( license) , f)
114
- } ) ,
115
- Node :: File { name, license } => {
116
- with_box ( fmt, |f| render_tree_license ( std:: iter:: once ( name) , Some ( license) , f) )
117
- }
118
- }
119
- }
120
- }
92
+ // impl std::fmt::Display for Node {
93
+ // fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
94
+ // match self {
95
+ // Node::Root { children } => {
96
+ // if children.len() > 1 {
97
+ // with_box(fmt, |f| {
98
+ // for child in children {
99
+ // writeln!(f, "{child}")?;
100
+ // }
101
+ // Ok(())
102
+ // })
103
+ // } else {
104
+ // for child in children {
105
+ // writeln!(fmt, "{child}")?;
106
+ // }
107
+ // Ok(())
108
+ // }
109
+ // }
110
+ // Node::Directory { name, children, license } => with_box(fmt, |f| {
111
+ // render_tree_license(std::iter::once(name), license.as_ref(), f)?;
112
+ // if !children.is_empty() {
113
+ // writeln!(f, "<p><b>Exceptions:</b></p>")?;
114
+ // for child in children {
115
+ // writeln!(f, "{child}")?;
116
+ // }
117
+ // }
118
+ // Ok(())
119
+ // }),
120
+ // Node::Group { files, directories, license } => with_box(fmt, |f| {
121
+ // render_tree_license(directories.iter().chain(files.iter()), Some(license), f)
122
+ // }),
123
+ // Node::File { name, license } => {
124
+ // with_box(fmt, |f| render_tree_license(std::iter::once(name), Some(license), f))
125
+ // }
126
+ // }
127
+ // }
128
+ // }
121
129
122
130
/// Draw a series of sibling files/folders, as HTML, into the given formatter.
123
131
fn render_tree_license < ' a > (
0 commit comments