@@ -119,7 +119,7 @@ pub fn parse(html: String) -> NodeRef {
119
119
kuchiki:: parse_html ( ) . one ( html)
120
120
}
121
121
122
- fn with_head < F : FnOnce ( & NodeRef ) > ( document : & mut NodeRef , f : F ) {
122
+ fn with_head < F : FnOnce ( & NodeRef ) > ( document : & NodeRef , f : F ) {
123
123
if let Ok ( ref node) = document. select_first ( "head" ) {
124
124
f ( node. as_node ( ) )
125
125
} else {
@@ -132,7 +132,7 @@ fn with_head<F: FnOnce(&NodeRef)>(document: &mut NodeRef, f: F) {
132
132
}
133
133
}
134
134
135
- fn inject_nonce ( document : & mut NodeRef , selector : & str , token : & str ) {
135
+ fn inject_nonce ( document : & NodeRef , selector : & str , token : & str ) {
136
136
if let Ok ( scripts) = document. select ( selector) {
137
137
for target in scripts {
138
138
let node = target. as_node ( ) ;
@@ -150,7 +150,7 @@ fn inject_nonce(document: &mut NodeRef, selector: &str, token: &str) {
150
150
151
151
/// Inject nonce tokens to all scripts and styles.
152
152
pub fn inject_nonce_token (
153
- document : & mut NodeRef ,
153
+ document : & NodeRef ,
154
154
dangerous_disable_asset_csp_modification : & DisabledCspModificationKind ,
155
155
) {
156
156
if dangerous_disable_asset_csp_modification. can_modify ( "script-src" ) {
@@ -162,14 +162,14 @@ pub fn inject_nonce_token(
162
162
}
163
163
164
164
/// Injects a content security policy to the HTML.
165
- pub fn inject_csp ( document : & mut NodeRef , csp : & str ) {
165
+ pub fn inject_csp ( document : & NodeRef , csp : & str ) {
166
166
with_head ( document, |head| {
167
167
head. append ( create_csp_meta_tag ( csp) ) ;
168
168
} ) ;
169
169
}
170
170
171
171
/// Injects a content security policy token to the HTML.
172
- pub fn inject_csp_token ( document : & mut NodeRef ) {
172
+ pub fn inject_csp_token ( document : & NodeRef ) {
173
173
inject_csp ( document, CSP_TOKEN )
174
174
}
175
175
@@ -239,7 +239,7 @@ impl Default for IsolationSide {
239
239
///
240
240
/// Note: This function is not considered part of the stable API.
241
241
#[ cfg( feature = "isolation" ) ]
242
- pub fn inject_codegen_isolation_script ( document : & mut NodeRef ) {
242
+ pub fn inject_codegen_isolation_script ( document : & NodeRef ) {
243
243
with_head ( document, |head| {
244
244
let script = NodeRef :: new_element ( QualName :: new ( None , ns ! ( html) , "script" . into ( ) ) , None ) ;
245
245
script. append ( NodeRef :: new_text (
@@ -257,7 +257,7 @@ pub fn inject_codegen_isolation_script(document: &mut NodeRef) {
257
257
///
258
258
/// Note: this does not prevent path traversal due to the isolation application expectation that it
259
259
/// is secure.
260
- pub fn inline_isolation ( document : & mut NodeRef , dir : & Path ) {
260
+ pub fn inline_isolation ( document : & NodeRef , dir : & Path ) {
261
261
for script in document
262
262
. select ( "script[src]" )
263
263
. expect ( "unable to parse document for scripts" )
@@ -297,8 +297,8 @@ mod tests {
297
297
"<html></html>" . to_string( ) ,
298
298
] ;
299
299
for html in htmls {
300
- let mut document = kuchiki:: parse_html ( ) . one ( html) ;
301
- super :: inject_csp_token ( & mut document) ;
300
+ let document = kuchiki:: parse_html ( ) . one ( html) ;
301
+ super :: inject_csp_token ( & document) ;
302
302
assert_eq ! (
303
303
document. to_string( ) ,
304
304
format!(
0 commit comments