Skip to content

Commit 56abd2b

Browse files
sypharjyn514
authored andcommitted
fix new clippy error
1 parent 1ce3fd8 commit 56abd2b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/web/csp.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::config::Config;
22
use iron::{AfterMiddleware, BeforeMiddleware, IronResult, Request, Response};
3+
use std::fmt::Write;
34

45
pub(super) struct Csp {
56
nonce: String,
@@ -67,7 +68,9 @@ impl Csp {
6768
// We can't just allow 'self' here, as users can upload arbitrary .js files as part of
6869
// their documentation and 'self' would allow their execution. Instead, every allowed
6970
// script must include the random nonce in it, which an attacker is not able to guess.
70-
result.push_str(&format!("; script-src 'nonce-{}'", self.nonce));
71+
//
72+
// This `.unwrap` is safe since the `Write` impl on str can never fail.
73+
write!(result, "; script-src 'nonce-{}'", self.nonce).unwrap();
7174
}
7275

7376
fn render_svg(&self, result: &mut String) {

0 commit comments

Comments
 (0)